Example #1
0
        private void CreateComment(CommentViewModel viewModel)
        {
            int userId = HttpContext.Current.User.Identity.GetUserId <int>();

            viewModel.CreatedAt = DateTime.Now;
            viewModel.IsEdited  = false;
            viewModel.UserId    = userId;

            _commentRepository.Add(viewModel.ToEntity());
        }
Example #2
0
 public ActionResult Create(CommentViewModel CommentModel, PictureViewModel Model)
 {
     if (CommentModel.Text != null)
     {
         var AccUserName      = User.Identity.Name;
         AccountViewModel acc = (Crud.GetAccount(AccUserName)).ToModel();
         CommentModel.Account = acc;
         CommentModel.Picture = Model;
         Crud.CreateComment(CommentModel.ToEntity());
     }
     return(List(Model.Id));
 }
        public ActionResult CreateComment(string comment, Guid AlbumRefId)
        {
            var model = new CommentViewModel();

            model.UserEmail  = User.Identity.Name;
            model.AlbumRefId = AlbumRefId;
            model.Id         = Guid.NewGuid();
            model.Text       = comment;
            CommentRepository.AddOrUppdate(model.ToEntity());

            return(Comment(AlbumRefId));
        }
Example #4
0
        public ActionResult Comment(FormCollection formData)
        {
            if (string.IsNullOrEmpty(formData["CommentText"]))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            var comment = new CommentViewModel
            {
                ClassId     = new Guid(formData["ClassId"]),
                CommentText = formData["CommentText"]
            };

            var classRepository = new ClassRepository(_context);
            var classInfo       = classRepository.GetClass(comment.ClassId, _loggedUser.Id, GetUserRole(_loggedUser));

            comment.DateTime = DateTime.Now;
            classRepository.SendComment(comment.ToEntity(_loggedUser, classInfo.Class));
            _context.Save(_loggedUser);

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }