Пример #1
0
        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));
        }
Пример #2
0
        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));
            }
        }
Пример #3
0
 public bool PostAuthor(Author author)
 {
     return(authors.Add(author));
 }