Exemple #1
0
        public void AddNewArtice(AddArticleBM bm, string username)
        {
            ApplicationUser currentUser = this.Context.Users.FirstOrDefault(user => user.UserName == username);
            Article         model       = Mapper.Map <AddArticleBM, Article>(bm);

            model.Author      = currentUser;
            model.PublishDate = DateTime.Today;
            this.Context.Articles.Add(model);
            this.Context.SaveChanges();
        }
        public ActionResult Add(AddArticleBM bm)
        {
            if (this.ModelState.IsValid)
            {
                string username = this.User.Identity.Name;
                this.service.AddNewArtice(bm, username);
                return(RedirectToAction("Articles"));
            }

            return(this.View());
        }