Exemplo n.º 1
0
        public async Task <PortfolioCommentDTO> CreatePortfolioComment(PortfolioCommentToCreateDTO commentToCreate)
        {
            PortfolioComment comment = ConvertCommentToCreate(commentToCreate);

            comment.PostedOn = DateTime.Now.Date;
            return(ConvertComment(await _genericRepo.AddAsync(comment)));
        }
Exemplo n.º 2
0
        public async Task <PortfolioCommentDTO> UpdatePortfolioComment(PortfolioCommentToUpdateDTO x)
        {
            PortfolioComment comment = await _commentRepo.GetPortfolioCommentByIdAsync(x.CommentId);

            comment.Message = x.Message;
            return(ConvertComment(await _genericRepo.UpdateAsync(comment)));
        }
Exemplo n.º 3
0
        private PortfolioComment ConvertCommentToCreate(PortfolioCommentToCreateDTO x)
        {
            if (x == null)
            {
                return(null);
            }

            PortfolioComment comment = new PortfolioComment
            {
                UserId      = x.UserId,
                PortfolioId = x.PortfolioId,
                Message     = x.Message
            };

            return(comment);
        }
Exemplo n.º 4
0
        private PortfolioCommentDTO ConvertComment(PortfolioComment x)
        {
            if (x == null)
            {
                return(null);
            }

            PortfolioCommentDTO comment = new PortfolioCommentDTO
            {
                CommentId   = x.PortfolioCommentId,
                UserId      = x.UserId,
                PortfolioId = x.PortfolioId,
                Message     = x.Message,
                PostedOn    = x.PostedOn.ToString("dd/MM/yyyy")
            };

            return(comment);
        }
Exemplo n.º 5
0
        public async Task <PortfolioCommentDTO> DeletePortfolioComment(int commentId)
        {
            PortfolioComment comment = await _commentRepo.GetPortfolioCommentByIdAsync(commentId);

            return(ConvertComment(await _genericRepo.DeleteAsync(comment)));
        }