Example #1
0
        private static PreliminaryDecisionComment MapAllegationPreliminaryDecisionComment(ComplaintComments.AllegationComment comment)
        {
            var result = new PreliminaryDecisionComment();

            result.Text = comment.Text;
            result.User = Mappers.MapUserToUserViewModel(comment.User);

            return result;
        }
Example #2
0
        private static List<AllegationWithMyComment> MapAllegationsWithMyComments(ComplaintComments.AllegationWithMyComment[] allegationWithMyComment)
        {
            var result = new List<AllegationWithMyComment>();

            foreach (var allegation in allegationWithMyComment)
                result.Add(Mappers.MapAllegationsWithMyComment(allegation));

            return result;
        }
Example #3
0
        private static AllegationWithComments MapAllegationWithComments(ComplaintComments.AllegationWithComments allegation)
        {
            var result = new AllegationWithComments();

            result.Id = allegation.Id;
            result.Text = allegation.Text;
            result.Documents = Mappers.MapDocuments(allegation.Documents);
            result.Comments = Mappers.MapMiniComments(allegation.Comments);

            return result;
        }
Example #4
0
        internal static ComplaintCommentsViewModel MapComments(ComplaintComments comments)
        {
            var result = new ComplaintCommentsViewModel();

            result.PreliminaryComments = Mappers.MapPreliminaryComments(comments.PreliminaryComments);
            result.PreliminaryDecision = Mappers.MapPreliminaryDecision(comments.PreliminaryDecisionComments);
            result.FinalDecision = Mappers.MapFinalDecision(comments.FinalDecisionApprovedByCurrentUser);
            result.FinalDecision.Document = Mappers.MapDocument(comments.FinalDecisionDocument);
            SetStatuses(comments.DueDate, comments.DueDaysLeft, comments.Status, result);

            return result;
        }
Example #5
0
        private static AllegationWithMyComment MapAllegationsWithMyComment(ComplaintComments.AllegationWithMyComment allegation)
        {
            var result = new AllegationWithMyComment();

            result.Id = allegation.Id;
            result.Text = allegation.Text;
            result.Documents = Mappers.MapDocuments(allegation.Documents);
            result.Comment = Mappers.MapMyAllegationComment(allegation.MyComment);
            if (allegation.OtherComments != null)
                result.OtherComments = Mappers.MapMiniComments(allegation.OtherComments);

            return result;
        }
Example #6
0
        public ComplaintComments GetComments(UserHeader user, int caseId)
        {
            var @case = _database.GetCaseById(caseId);
            var status = GetCaseState(@case);

            var users = GetUsers().Select(x => new Contract.User
            {
                Id = x.Id,
                Email = x.Email,
                FirstName = x.FirstName,
                LastName = x.LastName,
                Role = (Contract.Role) x.Role,
            }).ToArray();

            var allegations = _database.GetAllegationComments(caseId, user.Id);
            var preliminaryDecisionComments = _database.GetPreliminaryDecisionComments(caseId);
            var finalDecisionComments = _database.GetFinalDecisionComments(caseId);

            var finalDecisionApprovedByCurrentUser =
                finalDecisionComments.Any(x => x.PanelMemberId == user.Id && x.Decision == FinalDecisionCommentKind.Accept);

            var allegationsWithOthersComments = allegations
                .Select(x => new ComplaintComments.AllegationWithComments
                {
                    Id = x.Allegation.Id,
                    Text = x.Allegation.Text,
                    Comments = x.Comments.Select(y => new ComplaintComments.AllegationComment
                    {
                        Id = y.Id,
                        Text = y.Text,
                        User = users.FirstOrDefault(u => u.Id == y.PanelMemberId),
                    }).ToArray(),
                    Documents =
                        x.Allegation.Documents.Select(d => new Contract.Cases.Document {Id = d.Id, Name = d.Name}).ToArray(),
                }).ToArray();

            var allegationWithMyComments = allegations.Where(x => x.Allegation.MyComment != null)
                .Select(x => new ComplaintComments.AllegationWithMyComment
                {
                    Id = x.Allegation.Id,
                    Text = x.Allegation.Text,
                    Documents =
                        x.Allegation.Documents.Select(d => new Contract.Cases.Document {Id = d.Id, Name = d.Name}).ToArray(),
                    MyComment = new Contract.Cases.MyAllegationComment
                    {
                        Id = x.Allegation.MyComment.Id,
                        AllegationCommentType =
                            (Contract.Cases.AllegationCommentType) x.Allegation.MyComment.AllegationCommentType,
                        Text = x.Allegation.MyComment.Text,
                        AdditionalText = x.Allegation.MyComment.AdditionalText,
                    },
                    OtherComments = x.Comments
                        .Where(c => c.PanelMemberId != user.Id)
                        .Select(c => new ComplaintComments.AllegationComment
                        {
                            Id = c.Id,
                            Text = c.Text,
                            User = users.FirstOrDefault(u => u.Id == c.PanelMemberId),
                        }).ToArray(),
                });

            var allegationWithNoComments = allegations.Where(x => x.Allegation.MyComment == null)
                .Select(x => new ComplaintComments.AllegationWithMyComment
                {
                    Id = x.Allegation.Id,
                    Text = x.Allegation.Text,
                    Documents =
                        x.Allegation.Documents.Select(d => new Contract.Cases.Document {Id = d.Id, Name = d.Name}).ToArray(),
                    MyComment = new Contract.Cases.MyAllegationComment
                    {
                        Id = Guid.Empty,
                        Text = null,
                        AdditionalText = null,
                        AllegationCommentType = Contract.Cases.AllegationCommentType.No,
                    },
                    OtherComments = x.Comments
                        .Where(c => c.PanelMemberId != user.Id)
                        .Select(c => new ComplaintComments.AllegationComment
                        {
                            Id = c.Id,
                            Text = c.Text,
                            User = users.FirstOrDefault(u => u.Id == c.PanelMemberId),
                        }).ToArray(),
                });
            var partiesComments = _database.GetPartiesComments(caseId);
            var result = new ComplaintComments
            {
                DueDate = status.DueByDate,
                DueDaysLeft = status.DueDaysLeft,
                Status = GetStatus(status),
                FinalDecisionApprovedByCurrentUser = finalDecisionApprovedByCurrentUser,
                PreliminaryComments = new ComplaintComments.PreliminaryCommentsData
                {
                    AllegationsWithComments = allegationsWithOthersComments,
                    AllegationsWithMyComments = allegationWithMyComments.Concat(allegationWithNoComments).ToArray(),
                },
                PreliminaryDecisionComments = new ComplaintComments.PreliminaryDecisionCommentsData
                {
                    Comments = preliminaryDecisionComments.Select(x => new ComplaintComments.AllegationComment
                    {
                        Text = x.Text,
                        User = users.FirstOrDefault(u => u.Id == user.Id),
                    }).ToArray(),
                    CommentsFromParies = partiesComments.Select(x => new ComplaintComments.CommentFromParties
                    {
                        Text = x.Text,
                        Documents = x.Documents.Select(d => new Contract.Cases.Document {Id = d.Id, Name = d.Name}).ToArray(),
                    }).ToArray(),
                    PreliminaryDecisionDocument = @case.PreliminaryDecisionDocument == null
                        ? null
                        : new Contract.Cases.Document
                        {
                            Id = @case.PreliminaryDecisionDocument.Id,
                            Name = @case.PreliminaryDecisionDocument.Name,
                        },
                },
                FinalDecisionDocument = @case.FinalDecisionDocument == null
                    ? null
                    : new Contract.Cases.Document
                    {
                        Id = @case.FinalDecisionDocument.Id,
                        Name = @case.FinalDecisionDocument.Name,
                    },
            };

            return result;
        }
Example #7
0
        private static AllegationMiniComment MapMiniComment(ComplaintComments.AllegationComment comment)
        {
            var result = new AllegationMiniComment();

            result.Id = comment.Id;
            result.Text = comment.Text;
            result.User = Mappers.MapUserToUserViewModel(comment.User);

            return result;
        }
Example #8
0
        private static void SetStatuses(DateTime? dueDate, int? dueDays, ComplaintComments.StatusKind status, ComplaintCommentsViewModel result)
        {
            var date = dueDate ?? DateTime.Now;
            var days = dueDays ?? 0;

            result.PreliminaryComments.DueDate = date;
            result.PreliminaryComments.DueDays = days;
            result.PreliminaryDecision.DueDate = date;
            result.PreliminaryDecision.DueDays = days;
            result.FinalDecision.DueDate = date;
            result.FinalDecision.DueDays = days;

            switch (status)
            {
                case ComplaintComments.StatusKind.PreliminaryComments:
                    SetRender(result, true, false, false);
                    SetState(result, ComplaintCommentsStepState.InProcess, ComplaintCommentsStepState.InProcess, ComplaintCommentsStepState.InProcess);
                    break;
                case ComplaintComments.StatusKind.PreliminaryDecisionComments:
                    SetRender(result, true, true, false);
                    SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.InProcess, ComplaintCommentsStepState.InProcess);
                    break;
                case ComplaintComments.StatusKind.PreliminaryDecisionWaiting:
                    SetRender(result, true, true, false);
                    SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.WaitingForPartiesComments, ComplaintCommentsStepState.InProcess);
                    break;
                case ComplaintComments.StatusKind.FinalDecisionComments:
                    SetRender(result, true, true, true);
                    SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.InProcess);
                    break;
                case ComplaintComments.StatusKind.FinalDecisionLocked:
                    SetRender(result, true, true, true);
                    SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Locked);
                    break;
                case ComplaintComments.StatusKind.Complete:
                    SetRender(result, true, true, true);
                    SetState(result, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Complete, ComplaintCommentsStepState.Complete);
                    break;
            }
        }
Example #9
0
        private static List<CommentFromParties> MapPreliminaryDecisionCommentsFromParties(ComplaintComments.CommentFromParties[] commentFromParties)
        {
            var result = new List<CommentFromParties>();

            foreach (var comment in commentFromParties)
                result.Add(Mappers.MapPreliminaryDecisionCommentFromParties(comment));

            return result;
        }
Example #10
0
        private static List<PreliminaryDecisionComment> MapPreliminaryDecisionComments(ComplaintComments.AllegationComment[] allegationComment)
        {
            var result = new List<PreliminaryDecisionComment>();

            foreach (var comment in allegationComment)
                result.Add(Mappers.MapAllegationPreliminaryDecisionComment(comment));

            return result;
        }
Example #11
0
        private static CommentFromParties MapPreliminaryDecisionCommentFromParties(ComplaintComments.CommentFromParties comment)
        {
            var result = new CommentFromParties();

            result.Title = comment.Text;
            result.Documents = Mappers.MapDocuments(comment.Documents);

            return result;
        }
Example #12
0
        private static ComplaintCommentsPreliminaryDecisionViewModel MapPreliminaryDecision(ComplaintComments.PreliminaryDecisionCommentsData preliminaryDecision)
        {
            var result = new ComplaintCommentsPreliminaryDecisionViewModel();

            result.PreliminaryDecisionDocument = Mappers.MapDocument(preliminaryDecision.PreliminaryDecisionDocument);
            result.Comments = Mappers.MapPreliminaryDecisionComments(preliminaryDecision.Comments);
            result.CommentsFromParties = Mappers.MapPreliminaryDecisionCommentsFromParties(preliminaryDecision.CommentsFromParies);

            return result;
        }
Example #13
0
        private static ComplaintCommentsPreliminaryCommentsViewModel MapPreliminaryComments(ComplaintComments.PreliminaryCommentsData preliminaryComments)
        {
            var result = new ComplaintCommentsPreliminaryCommentsViewModel();

            result.AllegationsWithComments = Mappers.MapAllegationsWithComments(preliminaryComments.AllegationsWithComments);
            result.AllegationsWithMyComments = Mappers.MapAllegationsWithMyComments(preliminaryComments.AllegationsWithMyComments);

            return result;
        }
Example #14
0
        private static List<AllegationMiniComment> MapMiniComments(ComplaintComments.AllegationComment[] allegationComment)
        {
            var result = new List<AllegationMiniComment>();

            foreach (var comment in allegationComment)
                result.Add(Mappers.MapMiniComment(comment));

            return result;
        }