public IActionResult Edit(Guid id) { var item = _todoRepo.GetById(id); var todovm = new ToDoViewModel { Description = item.Description, ID = item.Id, IsComplete = item.IsComplete, Title = item.Title }; var vm = new EditViewModel { Item = todovm, Referrer = Request.Headers["referer"] }; return View(vm); }
public IActionResult Edit(EditViewModel vmitem) { if(ModelState.IsValid && vmitem.Item.ID.HasValue) { var matchItem = _todoRepo.GetById(vmitem.Item.ID.Value); matchItem.Title = vmitem.Item.Title; matchItem.Description = vmitem.Item.Description; matchItem.IsComplete = vmitem.Item.IsComplete; matchItem.UpdatedDate = DateTime.Now; matchItem.UpdatedBy = _userService?.UserName; _todoRepo.Update(matchItem); } if( string.IsNullOrEmpty(vmitem.Referrer)) { return RedirectToAction("index"); } else { return Redirect(vmitem.Referrer); } }