Exemplo n.º 1
0
        public async Task <long> AddCommentsAsync(long changeRequestId, CommentsStaging commentsStaging,
                                                  string approvedBy)
        {
            long reviewCommentId = 0;

            if (commentsStaging != null)
            {
                CommentsStaging changeRequestCommentsStaging = new CommentsStaging()
                {
                    Id              = 0,
                    Comment         = commentsStaging.Comment,
                    ChangeRequestId = Convert.ToInt64(changeRequestId.ToString()),
                    AddedBy         = approvedBy,
                    CreatedDatetime = DateTime.UtcNow
                };

                this.CommentsStagingBusinessService.Add(changeRequestCommentsStaging);

                if (await this.CommentsStagingBusinessService.SaveChangesAsync() > 0)
                {
                    reviewCommentId = changeRequestCommentsStaging.Id;
                }
            }
            return(reviewCommentId);
        }
        public async Task <bool> ProcessAsync(long changeRequestId, string approvedBy,
                                              CommentsStaging commentsStaging = null, List <AttachmentsStaging> attachments = null)
        {
            long reviewCommentId = 0;

            try
            {
                reviewCommentId = await AddCommentsAsync(changeRequestId, commentsStaging, approvedBy);

                var changeRequestStaging = await UpdateChangeRequestStatusAsync(changeRequestId);
                await SaveAttachmentsAsync(attachments, changeRequestStaging);

                if (await this.Repositories.SaveChangesAsync() > 0)
                {
                    await UpdateChangeRequestStatusToChangeRequestIndexAsync(changeRequestId,
                                                                             ChangeRequestStatus.PreliminaryApproved, reviewCommentId);
                }
            }
            catch (Exception e)
            {
                if (reviewCommentId > 0)
                {
                    await this.CommentsStagingBusinessService.RemoveAsync(reviewCommentId);

                    await this.CommentsStagingBusinessService.SaveChangesAsync();
                }
                throw;
            }


            return(true);
        }
Exemplo n.º 3
0
        public async Task <bool> ProcessAsync(long changeRequestId, string approvedBy,
                                              CommentsStaging commentsStaging = null, List <AttachmentsStaging> attachments = null)
        {
            long reviewCommentId = 0;

            try
            {
                reviewCommentId = await AddCommentsAsync(changeRequestId, commentsStaging, approvedBy);

                var changeRequestStaging = await UpdateChangeRequestStatusAsync(changeRequestId);
                await SaveAttachmentsAsync(attachments, changeRequestStaging);

                var changeRequestStore =
                    await AddToChangeRequestStoreAsync(changeRequestId, ChangeRequestStatus.Approved, approvedBy);

                var removedChangeRequestStaging = await RemoveFromChangeRequestStagingAsync(changeRequestId);

                if (changeRequestStore != null && removedChangeRequestStaging != null)
                {
                    var isTansactionalTableUpdated = await this.UpdateToTransactionalTableAsync(changeRequestStore, changeRequestId);

                    if (isTansactionalTableUpdated)
                    {
                        if (await this.Repositories.SaveChangesAsync() > 0)
                        {
                            await UpdateChangeRequestStatusToChangeRequestIndexAsync(changeRequestId,
                                                                                     ChangeRequestStatus.Approved, reviewCommentId);
                        }
                    }
                }
            }
            catch (DbEntityValidationException e)
            {
                if (reviewCommentId > 0)
                {
                    await this.CommentsStagingBusinessService.RemoveAsync(reviewCommentId);

                    await this.CommentsStagingBusinessService.SaveChangesAsync();
                }
                if (e.EntityValidationErrors != null)
                {
                    foreach (var error in e.EntityValidationErrors)
                    {
                        if (error.ValidationErrors.FirstOrDefault().ErrorMessage != null)
                        {
                            throw new Exception(error.ValidationErrors.FirstOrDefault().ErrorMessage);
                        }
                    }
                }
                else
                {
                    throw e;
                }
            }


            return(true);
        }
Exemplo n.º 4
0
        protected CommentsStaging MakeCommentsStaging(CommentsStagingModel comment, String addedBy)
        {
            // make change request comments staging.
            CommentsStaging changeRequestCommentsStaging = new CommentsStaging()
            {
                Id              = 0,
                Comment         = comment.Comment,
                AddedBy         = addedBy,
                CreatedDatetime = DateTime.UtcNow
            };

            return(changeRequestCommentsStaging);
        }
Exemplo n.º 5
0
        public virtual async Task <long> SubmitAddChangeRequestAsync(T entity, string requestedBy, List <ChangeRequestItemStaging> changeRequestItemStagings = null,
                                                                     CommentsStagingModel comment = null, List <AttachmentsModel> attachments = null, string changeContent = null)
        {
            // make change request comments stagings.
            CommentsStaging changeRequestCommentsStaging = null;

            if (comment != null)
            {
                changeRequestCommentsStaging = this.MakeCommentsStaging(comment, requestedBy);
            }

            return
                (await
                 ChangeRequestBusinessService.SubmitAsync(entity, 0, requestedBy, ChangeType.Add,
                                                          changeRequestItemStagings, changeRequestCommentsStaging,
                                                          MakeAttachmentsStaging(attachments, requestedBy), changeContent));
        }
Exemplo n.º 6
0
        public virtual async Task <long> SubmitReplaceChangeRequestAsync <TId>(T entity, TId id, string requestedBy, List <ChangeRequestItemStaging> changeRequestItemStagings = null,
                                                                               CommentsStagingModel comment = null, List <AttachmentsModel> attachments = null, string changeContent = null)
        {
            CommentsStaging           changeRequestCommentsStaging   = null;
            List <AttachmentsStaging> changeRequestAttachmentStaging = null;

            if (comment != null)
            {
                changeRequestCommentsStaging = this.MakeCommentsStaging(comment, requestedBy);
            }
            if (attachments != null)
            {
                changeRequestAttachmentStaging = this.MakeAttachmentsStaging(attachments, requestedBy);
            }

            return(await ChangeRequestBusinessService.SubmitAsync(entity, id, requestedBy,
                                                                  ChangeType.Replace, changeRequestItemStagings, changeRequestCommentsStaging, changeRequestAttachmentStaging, changeContent));
        }
Exemplo n.º 7
0
        public override async Task <bool> SubmitChangeRequestReviewAsync <TId>(TId changeRequestId, ChangeRequestReviewModel review)
        {
            // make CommentStaging
            CommentsStaging           changeRequestCommentsStaging = null;
            List <AttachmentsStaging> attachments = null;

            if (!string.IsNullOrEmpty(review.ReviewComment.Comment))
            {
                changeRequestCommentsStaging = this.MakeCommentsStaging(review.ReviewComment, review.ReviewedBy);
            }

            if (review.Attachments != null)
            {
                attachments = this.MakeAttachmentsStaging(review.Attachments, review.ReviewedBy);
            }

            return(await this.ChangeRequestBusinessService.SubmitReviewAsync(changeRequestId, review.ReviewedBy,
                                                                             review.ReviewStatus, changeRequestCommentsStaging, attachments));
        }
Exemplo n.º 8
0
        public async Task <bool> ProcessAsync(long changeRequestId, string rejectedBy,
                                              CommentsStaging commentsStaging = null, List <AttachmentsStaging> attachments = null)
        {
            long reviewCommentId = 0;

            try
            {
                reviewCommentId = await AddCommentsAsync(changeRequestId, commentsStaging, rejectedBy);

                var changeRequestStaging = await UpdateChangeRequestStatusAsync(changeRequestId);
                await SaveAttachmentsAsync(attachments, changeRequestStaging);

                var changeRequestStore =
                    await AddToChangeRequestStoreAsync(changeRequestId, ChangeRequestStatus.Rejected, rejectedBy);

                var removedChangeRequestStaging = await RemoveFromChangeRequestStagingAsync(changeRequestId);

                if (changeRequestStore != null && removedChangeRequestStaging != null)
                {
                    var isTansactionalTableUpdated = await this.UpdateToTransactionalTableAsync(changeRequestStore, changeRequestId);

                    if (isTansactionalTableUpdated)
                    {
                        if (await this.Repositories.SaveChangesAsync() > 0)
                        {
                            await UpdateChangeRequestStatusToChangeRequestIndexAsync(changeRequestId,
                                                                                     ChangeRequestStatus.Rejected, reviewCommentId);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (reviewCommentId > 0)
                {
                    await this.CommentsStagingBusinessService.RemoveAsync(reviewCommentId);

                    await this.CommentsStagingBusinessService.SaveChangesAsync();
                }
                throw;
            }
            return(true);
        }