public ActionResult Add(AuthorCreateVM model) { if (model == null) { return(View()); } if (ModelState.IsValid) { try { authorLogic.Add(new Entities.Author() { FirstName = model.FirstName, LastName = model.LastName }); } catch (System.Exception e) { if (e is DalException) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } else { logger.Warning("BL", e); } } logger.Info("Author was added", "Presentation layer, class AuthorController, method ActionResult Create(AuthorCreateVM)"); } return(View(model)); }
public ActionResult Create(CreateAuthorViewModel model) { var author = mapper.Map <CreateAuthorViewModel, Author>(model); try { if (ModelState.IsValid) { if (authorLogic.Add(author)) { return(RedirectToAction("Index")); } } return(View(model)); } catch { return(View(model)); } }
public bool PostAuthor(Author author) { return(authors.Add(author)); }