// GET: Authors/Details/5 public async Task <ActionResult> Details(int?id) { Author author; AuthorViewModel model; try { if (id == null) { //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); return(PartialView("PartialNotFoundView", id.ToString())); } author = await db.Authors.FindAsync(id); if (author == null) { //return HttpNotFound(); return(PartialView("PartialNotFoundView", id.ToString())); } model = AuthorRelase.DetailsAuthor(author); return(View(model)); } catch { return(RedirectToAction("Index")); } }
public ActionResult Index() { try { var authors = db.Authors.ToList(); AuthorListModel model = new AuthorListModel { AuthorsList = AuthorRelase.GetAuthorsResult(authors) }; return(View(model.AuthorsList)); } catch { return(RedirectToAction("Index")); } }
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> Create([Bind(Include = "Id,FullName,DateBirth")] AuthorViewModel model) { try { if (ModelState.IsValid) { var author = AuthorRelase.CreateAuthor(model); db.Authors.Add(author); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(model)); } catch { return(RedirectToAction("Index")); } }