Created
April 2, 2018 04:15
-
-
Save gsedubun/99015fed1e39d591ecacdc010e01df31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using Microsoft.AspNetCore.Mvc; | |
using TodoNetCoreAngular.Models; | |
namespace TodoNetCoreAngular.Controllers | |
{ | |
[Route("api/[controller]")] | |
public class TodoController : Controller | |
{ | |
private readonly TodoRepository todos; | |
public TodoController(TodoRepository _todos) | |
{ | |
this.todos = _todos; | |
} | |
[HttpGet] | |
[Route("[action]")] | |
public IActionResult Index() | |
{ | |
return Ok(todos.Get()); | |
} | |
[HttpGet] | |
[Route("[action]")] | |
public IActionResult GetItem(int todoId) | |
{ | |
var data = todos.GetTodoItem(todoId); | |
return Ok(data); | |
} | |
[HttpGet] | |
[Route("[action]")] | |
public IActionResult Get(int id) | |
{ | |
var data = todos.Get(id); | |
return Ok(data); | |
} | |
[HttpPost] | |
[Route("[action]")] | |
public IActionResult Additem(int id, [FromBody] TodoItem todoItem) | |
{ | |
var data = todos.Addtodoitem(id,todoItem); | |
return Ok(data); | |
} | |
[HttpPost] | |
[Route("[action]")] | |
public IActionResult Addtodo([FromBody] Todo todo) | |
{ | |
var data= todos.Addtodo(todo);; | |
return Ok(data); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment