Exemplo n.º 1
0
 public ActionResult Create(AuthorModel author)
 {
     try
     {
         var authorBL = new AuthorBL {
             ArticleId = author.ArticleId, FirstName = author.FirstName, LastName = author.LastName, NickName = author.NickName
         };
         authorService.Create(authorBL);
         return(Content("<h2>Completed</h2>"));
     }
     catch (ValidationException ex)
     {
         ModelState.AddModelError(ex.Property, ex.Message);
     }
     return(View(author));
 }
Exemplo n.º 2
0
        public void Create(AuthorBL authorBL)
        {
            Article article = Database.Articles.Get(authorBL.ArticleId);

            if (article == null)
            {
                throw new ValidationException("no article", "");
            }

            Author author = new Author
            {
                FirstName = authorBL.FirstName,
                LastName  = authorBL.LastName,
                NickName  = authorBL.NickName,
            };

            Database.Authors.Create(author);
            Database.Save();
        }