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)); }
[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)); }