public async Task <ActionResult> Edit(TaskItem item) { if (!ModelState.IsValid) { return(View(item)); } await _itemsRepo.UpdateItemAsync(item.Id, item); return(RedirectToAction("Index")); }
public async Task <ActionResult <TaskItem> > UpdateAsync(string id, TaskItem taskItem) { if (!User.Identity.IsAuthenticated) { return(Unauthorized()); } if (!(id?.Equals(taskItem.Id) == true && User.Identity.Name?.Equals(taskItem.Owner) == true)) { return(BadRequest()); } var updatedItem = await _itemsRepo.UpdateItemAsync(id, taskItem); if (updatedItem == null) { return(BadRequest()); } return(Ok(updatedItem)); }