Пример #1
0
        public List <DtoAssetComment> GetComments(int assetId)
        {
            var commentIds = _uow.AssetCommentRepository.Get(x => x.AssetId == assetId).Select(x => x.CommentId).ToList();

            if (commentIds.Count == 0)
            {
                return(new List <DtoAssetComment>());
            }

            var list = new List <DtoAssetComment>();

            foreach (var commentId in commentIds)
            {
                var comment = _uow.CommentRepository.GetById(commentId);
                if (comment == null)
                {
                    continue;
                }
                var assetComment = new DtoAssetComment();
                assetComment.Comment     = comment.CommentText;
                assetComment.CommentTime = comment.CommentTime;
                assetComment.Username    = comment.Username;
                list.Add(assetComment);
            }

            return(list.OrderByDescending(x => x.CommentTime).ToList());
        }
Пример #2
0
 public DtoActionResult AddComment(DtoAssetComment comment)
 {
     Request.Method   = Method.POST;
     Request.Resource = string.Format("{0}/AddComment/", Resource);
     Request.AddJsonBody(comment);
     return(new ApiRequest().Execute <DtoActionResult>(Request));
 }
Пример #3
0
        protected void buttonUpdate_OnClick(object sender, EventArgs e)
        {
            var dtoComment = new DtoAssetComment();

            dtoComment.AssetId = Asset.Id;
            dtoComment.Comment = txtComment.Text.Replace("\r\n", "<br>");
            var result = Call.AssetApi.AddComment(dtoComment);

            if (!result.Success)
            {
                EndUserMessage = result.ErrorMessage;
                return;
            }

            PopulateComments();
        }
Пример #4
0
        public DtoActionResult AddComment(DtoAssetComment comment, int userId)
        {
            if (string.IsNullOrEmpty(comment.Comment))
            {
                return(new DtoActionResult()
                {
                    ErrorMessage = "Comments Cannot Be Empty"
                });
            }

            var user = new ServiceUser().GetUser(userId);

            if (user == null)
            {
                return new DtoActionResult()
                       {
                           ErrorMessage = "Could Not Determine Current User"
                       }
            }
            ;

            var entityComment = new EntityComment();

            entityComment.CommentText = comment.Comment;
            entityComment.CommentTime = DateTime.Now;
            entityComment.Username    = user.Name;
            _uow.CommentRepository.Insert(entityComment);
            _uow.Save();

            var assetComment = new EntityAssetComment();

            assetComment.AssetId   = comment.AssetId;
            assetComment.CommentId = entityComment.Id;
            _uow.AssetCommentRepository.Insert(assetComment);
            _uow.Save();

            return(new DtoActionResult()
            {
                Success = true, Id = assetComment.Id
            });
        }
Пример #5
0
 public DtoActionResult AddComment(DtoAssetComment comment)
 {
     return(_serviceAsset.AddComment(comment, _userId));
 }