public async Task <ActionResult <ToDoItemViewModel> > Put(ToDoItemUpdateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var toDoItemObj = await _context.ToDoItems.FindAsync(model.Id);

            if (toDoItemObj == null)
            {
                return(NotFound("Item with required id not found"));
            }

            toDoItemObj = _mapper.Map(model, toDoItemObj);
            _context.ToDoItems.Update(toDoItemObj);
            await _context.SaveChangesAsync();

            var updatedToDoItem = await _context.ToDoItems.FindAsync(toDoItemObj.Id);

            var mappedItem = _mapper.Map <ToDoItemViewModel>(updatedToDoItem);

            return(Ok(mappedItem));
        }
Exemple #2
0
 public async Task <ToDoItem> UpdateAsync(string id, ToDoItemUpdateModel updateModel)
 {
     return(null);
 }