Ejemplo n.º 1
0
        public ActionResult AddPostComment(int id)
        {
            var model = new BlogPostCommentAddViewModel();
            model.BlogPostId = id;
            model.IsAnonymous = !User.Identity.IsAuthenticated;

            return PartialView("_AddPostComment", model);
        }
Ejemplo n.º 2
0
        public ActionResult AddPostComment(int id)
        {
            var model = new BlogPostCommentAddViewModel();

            model.BlogPostId  = id;
            model.IsAnonymous = !User.Identity.IsAuthenticated;

            return(PartialView("_AddPostComment", model));
        }
Ejemplo n.º 3
0
 public ActionResult Edit(BlogPostCommentAddViewModel model)
 {
     if (ModelState.IsValid)
     {
         blogPostCommentService.AddOrUpdate(model);
         return(RedirectToAction("Index")
                .WithSuccess(string.Format("The comment \"{0}\" has been updated".TA(), model.Name)));
     }
     return(View(model));
 }
Ejemplo n.º 4
0
        public ActionResult AddPostComment(BlogPostCommentAddViewModel model)
        {
            //  var comment = Mapper.Map<BlogPostComment>(model);
            if (User.Identity.IsAuthenticated)
            {
                model.UserId = currentUser.User.Id;
                model.Name = currentUser.User.FirstName;
                model.Email = currentUser.User.Email;
            }

            blogPostCommentService.AddOrUpdate(model);
            var action = RedirectToAction("Post", new {id = model.BlogPostId});
            return action.WithSuccess(string.Format("The comment has been added".TA()));
        }
Ejemplo n.º 5
0
        public ActionResult AddPostComment(BlogPostCommentAddViewModel model)
        {
            //  var comment = Mapper.Map<BlogPostComment>(model);
            if (User.Identity.IsAuthenticated)
            {
                model.UserId = currentUser.User.Id;
                model.Name   = currentUser.User.FirstName;
                model.Email  = currentUser.User.Email;
            }

            blogPostCommentService.AddOrUpdate(model);
            var action = RedirectToAction("Post", new { id = model.BlogPostId });

            return(action.WithSuccess(string.Format("The comment has been added".TA())));
        }
Ejemplo n.º 6
0
        public BlogPostComment AddOrUpdate(BlogPostCommentAddViewModel model)
        {
            BlogPostComment comment;

            if (model.Id == 0)
            {
                comment = Mapper.Map <BlogPostComment>(model);
                db.BlogPostComments.Add(comment);
            }
            else
            {
                comment = Find(model.Id);
                Mapper.Map(model, comment);
            }

            db.SaveChanges();

            return(comment);
        }
Ejemplo n.º 7
0
        public BlogPostComment AddOrUpdate(BlogPostCommentAddViewModel model)
        {
            BlogPostComment comment;
            if (model.Id == 0)
            {
                comment = Mapper.Map<BlogPostComment>(model);
                db.BlogPostComments.Add(comment);
            }
            else
            {
                comment = Find(model.Id);
                Mapper.Map(model, comment);

            }

            db.SaveChanges();

            return comment;
        }
 public ActionResult Edit(BlogPostCommentAddViewModel model)
 {
     if (ModelState.IsValid)
     {
         blogPostCommentService.AddOrUpdate(model);
         return RedirectToAction("Index")
             .WithSuccess(string.Format("The comment \"{0}\" has been updated".TA(), model.Name));
     }
     return View(model);
 }