public ActionResult Add(AuthorModel model) { if (ModelState.IsValid) { var author = Mapper.Map<AuthorModel, Author>(model); _authorRepository.Insert(author); return RedirectToAction("Index", new { message = (int)AuthorsListSuccessMessage.AuthorAddedSuccesfully }); } model.IsEditMode = false; return View("Edit", model); }
public ActionResult Edit(AuthorModel model) { if (ModelState.IsValid) { var author = _authorRepository.Get(model.Id); if (author == null) return RedirectToAction("Index"); author = Mapper.Map(model, author); _authorRepository.Save(author); return RedirectToAction("Index", new { message = (int)AuthorsListSuccessMessage.AuthorEditedSuccesfully }); } model.IsEditMode = true; return View(model); }