Пример #1
0
        public ActionResult CreateComment(CommentViewModel model)
        {
            if (ModelState.IsValid && model.Id != 0)
            {
                CommentDataModel commentDataModel = new CommentDataModel();
                string           user             = GetUserDetail();
                model.UserName = user.Split('|')[0];
                model.UserId   = Convert.ToInt32(user.Split('|')[1]);
                model.EventId  = model.Id;
                model.Date     = DateTime.Now;

                commentDataModel.UserName = model.UserName;
                commentDataModel.UserId   = model.UserId;
                commentDataModel.Comment  = model.Comment;
                commentDataModel.Date     = model.Date;
                commentDataModel.EventId  = model.EventId;

                CommentService commentService = new CommentService();
                var            result         = commentService.CreateComments(commentDataModel);

                if (result == null)
                {
                    ModelState.AddModelError("", "Something went wrong...");
                    return(View());
                }
            }
            ModelState.Clear();
            return(View());
        }