Ejemplo n.º 1
0
        public void AddComment(CommentViewModel model, DateTime myDate)
        {
            var comment = _autoMapper.Map <Comment>(model);

            comment.date = myDate;
            _commentsRepository.AddComment(comment);
        }
Ejemplo n.º 2
0
        public void AddComment(CommentViewModel model)
        {
            var comment = _autoMapper.Map <Comment>(model);

            comment.SubmissionFK = comment.Submission.Id;
            comment.Submission   = null;
            _comrepo.AddComment(comment);
        }
Ejemplo n.º 3
0
        public void AddComment(CommentViewModel model, DateTime createdDate, string commenterEmail)
        {
            var comm = _autoMapper.Map <Comment>(model);

            comm.SubmissionId   = comm.submission.id;
            comm.submission     = null;
            comm.commentDate    = createdDate;
            comm.commenterEmail = commenterEmail;

            _commentRepo.AddComment(comm);
        }
        public async Task <IActionResult> AddComment([FromBody] CommentsDTO commentInfo)
        {
            bool added = await _commentsRepository.AddComment(commentInfo);

            if (!added)
            {
                return(BadRequest(new { message = "Failed to save comment" }));
            }

            return(Ok(new { message = "Comment saved" }));
        }
Ejemplo n.º 5
0
        public async void AddComment_ShouldPass(string postText, string commentText)
        {
            var post = await _postrepository.AddPost(new Post { Text = postText });

            var firstComments = post.Comments?.ToList();

            await _commentsRepository.AddComment(new Comment { Post = post, Text = commentText });

            var secondComments = post.Comments.First();

            Assert.Null(firstComments);
            Assert.Equal(commentText, secondComments.Text);
        }
Ejemplo n.º 6
0
        public PartialViewResult AddComment(int articleId, String sender, String body)
        {
            sender = sender?.Trim();
            body   = body?.Trim();

            commentsRepository.AddComment(articleId, new Comment
            {
                Body         = body,
                Sender       = sender,
                CreationDate = DateTime.Now,
            });

            return(GetComments(articleId));
        }
Ejemplo n.º 7
0
 public async Task <Comment> AddComment(Comment comment)
 {
     if (comment == null)
     {
         throw new ArgumentException(nameof(comment));
     }
     if (comment.Post == null)
     {
         throw new ArgumentNullException(nameof(comment.Post), "Post cannot be null.");
     }
     if (string.IsNullOrWhiteSpace(comment.Text))
     {
         throw new ArgumentNullException(nameof(comment.Text), "Text cannot be null.");
     }
     return(await _repository.AddComment(comment));
 }
Ejemplo n.º 8
0
        public JsonResult Add_Comment([Bind(Include = "Description,ItemID")] Comment comment)
        {
            comment.UserID = User.Identity.GetUserId();
            JsonResult result = new JsonResult {
                Data = "Invalid Model."
            };

            if (ModelState.IsValid)
            {
                try
                {
                    result = _commentsRepository.AddComment(comment);
                }
                catch (Exception ex)
                {
                    result = new JsonResult {
                        Data = "Error: " + ex.InnerException
                    };
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
        public async Task AddComment(Guid PostId, Guid AuthorId, Guid CommentId, string Text)
        {
            Comment comment = new Comment()
            {
                PostId = PostId,
                Author = new User()
                {
                    Id = AuthorId
                },
                CommentId = CommentId,
                Text      = Text
            };

            if (comment.IsValidData())
            {
                await _commentsRepository.AddComment(comment);
            }
            else
            {
                throw new ArgumentException("Invalid arguments");
            }
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> AddComment([FromBody] CommentDto comment)
        {
            try
            {
                Comment entity = Mapper.Map <Comment>(comment);

                DateTime now = DateTime.UtcNow;

                entity.CreatedDateTime  = now;
                entity.ModifiedDateTime = now;
                entity.Approved         = true;

                await _commentsRepository.AddComment(entity);

                await _commentsRepository.SaveChanges();
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }

            return(Ok());
        }
Ejemplo n.º 11
0
 public void AddComment(CommentViewModel comment)
 {
     _commentsRepo.AddComment(_mapper.Map <Comment>(comment));
 }
Ejemplo n.º 12
0
 public async Task <IActionResult> Add([FromBody] CommentsVM cmt)
 {
     return(Ok(await _commentRepository.AddComment(cmt)));
 }
Ejemplo n.º 13
0
 public void AddComment(Koment k)
 {
     repository.AddComment(k);
 }
 public void AddComment(CommentViewModel model)
 {
     _commentsRepo.AddComment(_autoMapper.Map <Comment>(model));
 }