Пример #1
0
        public bool CreatePostReply(PostReplyCreate model, int postID)
        {
            var entity = new PostReply()
            {
                ReplyCreator = _userID,
                ReplyContent = model.ReplyContent,
                PostID       = postID,
                ReplyCreated = DateTimeOffset.Now
            };

            _dbContext.Replies.Add(entity);
            return(_dbContext.SaveChanges() == 1);
        }
        public ActionResult Create(PostReplyCreate model, int postID)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateReplyService();

            if (service.CreatePostReply(model, postID))
            {
                TempData["SaveResult"] = "Your reply was created.";
                return(RedirectToAction("PostRepliesIndex", new { postID = postID }));
            }

            ModelState.AddModelError("", "Reply could not be created.");
            return(View(model));
        }