Пример #1
0
        public ActionResult Create(FormCollection formCollection, CommentViewModel vo)
        {
            if (ModelState.IsValid)
            {
                var targetEntity = _commentRepository.Find(c => c.Id == vo.ReplyId);
                if (targetEntity == null)
                {
                    ModelState.AddModelError(string.Empty, "没有指定回复的评论");
                    return(View(vo));
                }
                var entity = MappingManager.CommentEntityMapping(vo);
                entity.ReplyUser   = targetEntity.CreatedUser;
                entity.CreatedUser = CurrentUser.CustomerId;
                entity.CreatedDate = DateTime.Now;
                entity.Status      = (int)DataStatus.Normal;
                entity.SourceId    = targetEntity.SourceId;
                entity.SourceType  = targetEntity.SourceType;
                entity.User_Id     = CurrentUser.CustomerId;
                entity.UpdatedUser = CurrentUser.CustomerId;
                entity.UpdatedDate = DateTime.Now;

                entity = this._commentRepository.Insert(entity);

                return(RedirectToAction("Details", new { id = entity.Id }));
            }

            return(View(vo));
        }