Exemple #1
0
 public IActionResult GetById(string id)
 {
     var item = TodoItems.Find(id);
     if (item == null)
         return HttpNotFound();
     return new ObjectResult(item);
 }
Exemple #2
0
        public IActionResult Delete(string id)
        {
            var todo = TodoItems.Find(id);

            if (todo == null)
            {
                return(HttpNotFound());
            }

            TodoItems.Remove(id);

            return(new NoContentResult());
        }
Exemple #3
0
        public IActionResult Update(string id, [FromBody] TodoItem item)
        {
            if (item == null || item.Key != id)
            {
                return(HttpBadRequest());
            }

            var todo = TodoItems.Find(id);

            if (todo == null)
            {
                return(HttpNotFound());
            }

            TodoItems.Update(item);

            return(new NoContentResult());
        }