public CommentResponseModel AddCommentToEstate(string userId, CommentRequestModel comment)
        {
            var user = this.users
                .GetById(userId);
            var newComment = new Comment()
            {
                Content = comment.Content,
                CreatedOn = DateTime.Now,
                EstateId = comment.RealEstateId,
                UserId = userId,
                User = user
            };

            user.Comments.Add(newComment);
            this.users.SaveChanges();

            var responseModel = new CommentResponseModel()
            {
                Content = newComment.Content,
                CreatedOn = newComment.CreatedOn,
                UserName = newComment.User.UserName
            };

            return responseModel;
        }
        public Comment CreateComment(Comment comment)
        {
            this.comments.Add(comment);
            this.comments.SaveChanges();

            return comment;
        }
        public int AddNew(Comment comment, string userId)
        {
            comment.CreatedOn = DateTime.UtcNow;
            comment.UserId = userId;

            this.comments.Add(comment);
            this.comments.SaveChanges();

            return comment.Id;
        }
Пример #4
0
        public int Create(int realEstateId, string content, string userId)
        {
            var newComment = new Comment()
            {
                Content = content,
                RealEstateId = realEstateId,
                UserId = userId
            };

            this.commentRepository.Add(newComment);
            this.commentRepository.SaveChanges();

            return newComment.Id;
        }