Пример #1
0
 public IActionResult Create([FromBody] NotToDo nottodo)
 {
     if (nottodo.Description == null || nottodo.Description == "")
     {
         return(BadRequest());
     }
     _context.NotToDos.Add(nottodo);
     _context.SaveChanges();
     return(CreatedAtRoute("GetNotTodo", new { id = nottodo.Id }, nottodo));
 }
Пример #2
0
        [Route("MyEdit")] // Custom route
        public IActionResult GetByParams([FromBody] NotToDo nottodo)
        {
            var item = _context.NotToDos.Where(t => t.Id == nottodo.Id).FirstOrDefault();

            if (item == null)
            {
                return(NotFound());
            }
            else
            {
                item.IsComplete = nottodo.IsComplete;
                _context.SaveChanges();
            }
            return(new ObjectResult(item));
        }