public void UpdateToDoItem(Guid listId, ToDoItemDTO item, string owner) { ToDoList toDoList = GetToDoList(listId, owner); if (toDoList == null) { throw new EntityNotFoundException(); } else if (toDoList.Owner != owner) { throw new UnauthorizedException(); } ToDoItem oldItem = toDoList.Items.SingleOrDefault(i => i.Id.Equals(item.Id)); if (oldItem == null) { throw new EntityNotFoundException(); } oldItem.Update(item.ToEntity(toDoList)); _context.SaveChanges(); }