public async Task <ActionResult> Edit([Bind(Include = "Id,FullName,DateBirth")] AuthorViewModel model) { try { if (ModelState.IsValid) { var author = AuthorRelase.EditAuthor(model); db.Entry(author).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); } catch { return(RedirectToAction("Index")); } }
public async Task <ActionResult> Edit(int?id) { try { if (id == null) { //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); return(PartialView("PartialNotFoundView", id.ToString())); } Author author = await db.Authors.FindAsync(id); if (author == null) { //return HttpNotFound(); return(PartialView("PartialNotFoundView", id.ToString())); } var model = AuthorRelase.EditAuthor(author); return(View(model)); } catch { return(RedirectToAction("Index")); } }