예제 #1
0
        public void Execute(CommentDto request)
        {
            validations.ValidateAndThrow(request);
            var commentt = mapper.Map <Comment>(request);

            context.Comments.Add(commentt);
            context.SaveChanges();
        }
        public void Execute(CommentDto request)
        {
            validator.ValidateAndThrow(request);
            request.UserId = actor.Id;
            var comment = mapper.Map <Comment>(request);

            context.Add(comment);
            context.SaveChanges();
        }
        public void Execute(CommentDto request, int id)
        {
            _validator.ValidateAndThrow(request);
            var comment = _context.Comments.Find(id);

            comment.Text = request.text;

            _context.SaveChanges();
        }
        public void Execute(CommentDto request)
        {
            _validator.ValidateAndThrow(request);

            var comment = _mapper.Map <Comment>(request);

            _context.Comments.Add(comment);

            _context.SaveChanges();
        }
        public void Execute(CommentDto request)
        {
            _validator.ValidateAndThrow(request);
            var comment = new Comment
            {
                CommentText = request.CommentText,
                PostId      = request.PostId,
                UserId      = _actor.Id
            };

            _context.Comments.Add(comment);
            _context.SaveChanges();
        }
예제 #6
0
        public void Execute(CommentDto request, int id)
        {
            _validator.ValidateAndThrow(request);
            var comment = new Comment
            {
                Text      = request.text,
                ArticleId = id,
                UserId    = _actor.Id
            };

            _context.Comments.Add(comment);
            _context.SaveChanges();
        }
        public void Execute(InsertCommentDto request)
        {
            validator.ValidateAndThrow(request);
            var comment = new Comments
            {
                IdPost  = request.PostId,
                Id      = request.Id,
                Comment = request.Comment,
                UserId  = request.UserId
            };

            _context.Comments.Add(comment);
            _context.SaveChanges();
        }
예제 #8
0
        public void Execute(CommentDto request)
        {
            validator.ValidateAndThrow(request);
            var comm = context.Comments.Find(request.Id);

            if (comm == null)
            {
                throw new EntityNotFoundException(request.Id, typeof(Comment));
            }

            var cyy = context.Comments.Where(x => x.Id == request.Id).First();

            mapper.Map(request, cyy);
            context.SaveChanges();
        }
예제 #9
0
        public void Execute(CommentDto request, int id)
        {
            var comment = _context.Comments.Find(id);

            if (comment == null)
            {
                throw new EntityNotFoundException(id, typeof(Comment));
            }

            _validator.ValidateAndThrow(request);

            comment.Text       = request.Text;
            comment.ModifiedAt = DateTime.Now;
            _context.SaveChanges();
        }
예제 #10
0
        public void Execute(CommentsDto request)
        {
            _validator.ValidateAndThrow(request);

            var comment = new Comments
            {
                Subject   = request.Subject,
                Text      = request.Text,
                ArticleId = request.ArticleId,
                UserId    = _actor.Id
            };



            _context.Comments.Add(comment);
            _context.SaveChanges();
        }
        public void Execute(CommentDto request)
        {
            _validator.ValidateAndThrow(request);

            _context.Comments.Include(x => x.User);

            var userId = _actor.Id;

            //var comment = _mapper.Map<Comment>(request);

            var comment = new Comment
            {
                Content = request.Content,
                PostId  = request.PostId,
                UserId  = userId
            };

            _context.Comments.Add(comment);

            _context.SaveChanges();
        }