public ActionResult Create(ArticleViewModel model)
        {
            try
            {
                var user         = User.Identity.Name;
                var loggedInUser = _userLogic.GetUserByEmail(user);

                Article article = new Article()
                {
                    Type = model.Type, Title = model.Title, SubTitle = model.SubTitle, Content = model.Content, AuthorId = loggedInUser.Id
                };
                var response = _articleLogic.Create(article);
                if (response.IsError == true)
                {
                    foreach (var item in response.ErrorCodes)
                    {
                        ModelState.AddModelError(string.Empty, item);
                    }
                    PrepareSelectList();
                    return(View(model));
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #2
0
 public bool Create(ArticleViewModel m)
 {
     if (m != null)
     {
         return(logic.Create(m));
     }
     return(false);
 }