public ChildAttachmentsProviderConfig(DocumentAttachmentModel parentAttachment)
        {
            Predicate = model =>
                        parentAttachment.ChildAttachmentDescriptors.Any(childDescriptor =>
                                                                        childDescriptor.ChildAttachmentId == model.Id);

            DecoratorTransform = DocumentDecoratorTransform;
        }
Пример #2
0
        public async Task <OpportunityViewModel> OpportunityToViewModelAsync(Opportunity entity, string requestId = "")
        {
            var oppId = entity.Id;

            try
            {
                //var entityDto = TinyMapper.Map<OpportunityViewModel>(entity);
                var viewModel = new OpportunityViewModel
                {
                    Id                   = entity.Id,
                    DisplayName          = entity.DisplayName,
                    Reference            = entity.Reference,
                    Version              = entity.Version,
                    OpportunityState     = OpportunityStateModel.FromValue(entity.Metadata.OpportunityState.Value),
                    OpportunityChannelId = entity.Metadata.OpportunityChannelId,
                    //TODO
                    TemplateLoaded = entity.TemplateLoaded,

                    //TODO : WAVE-4 GENERIC ACCELERATOR Change : start
                    MetaDataFields = entity.Metadata.Fields.Select(
                        field => new OpportunityMetaDataFields()
                    {
                        DisplayName = field.DisplayName,
                        FieldType   = field.FieldType,
                        Screen      = field.Screen,
                        Values      = field.Values
                    }
                        ).ToList(),
                    //TODO : WAVE-4 GENERIC ACCELERATOR Change : end
                    Customer = new CustomerModel
                    {
                        DisplayName = entity.Metadata.Customer.DisplayName,
                        Id          = entity.Metadata.Customer.Id,
                        ReferenceId = entity.Metadata.Customer.ReferenceId
                    },
                    TeamMembers = new List <TeamMemberModel>(),
                    Notes       = new List <NoteModel>(),
                    Checklists  = new List <ChecklistModel>()
                };

                //DealType
                var dealTypeFlag = false;
                dealTypeFlag = entity.Content.Template is null || entity.Content.Template.Id is null;
                if (!dealTypeFlag)
                {
                    viewModel.Template = await _templateHelpers.MapToViewModel(entity.Content.Template);

                    //DealType Processes
                    var checklistPass = false;
                    foreach (var item in entity.Content.Template.ProcessList)
                    {
                        if (item.ProcessType.ToLower() == "checklisttab" && checklistPass == false)
                        {
                            viewModel = await _checkListProcessService.MapToModelAsync(entity, viewModel, requestId);

                            checklistPass = true;
                        }
                        if (item.ProcessType.ToLower() == "customerdecisiontab")
                        {
                            viewModel = await _customerDecisionProcessService.MapToModelAsync(entity, viewModel, requestId);
                        }
                        if (item.ProcessType.ToLower() == "customerfeedbacktab")
                        {
                            viewModel = await _customerFeedbackProcessService.MapToModelAsync(entity, viewModel, requestId);
                        }
                        if (item.ProcessType.ToLower() == "proposalstatustab")
                        {
                            viewModel = await _proposalStatusProcessService.MapToModelAsync(entity, viewModel, requestId);
                        }
                    }
                }


                // TeamMembers
                foreach (var item in entity.Content.TeamMembers.ToList())
                {
                    var memberModel = new TeamMemberModel();
                    memberModel.RoleId            = item.RoleId; //await _userProfileHelpers.RoleToViewModelAsync(item.AssignedRole, requestId);
                    memberModel.Id                = item.Id;
                    memberModel.DisplayName       = item.DisplayName;
                    memberModel.Mail              = item.Fields.Mail;
                    memberModel.UserPrincipalName = item.Fields.UserPrincipalName;
                    memberModel.Title             = item.Fields.Title ?? String.Empty;
                    memberModel.ProcessStep       = item.ProcessStep;
                    memberModel.Permissions       = new List <PermissionModel>();
                    memberModel.AdGroupName       = await _graphUserAppService.GetAdGroupName(item.RoleId, requestId);

                    memberModel.RoleName = item.RoleName;
                    foreach (var permission in item.Fields.Permissions)
                    {
                        memberModel.Permissions.Add(new PermissionModel {
                            Id = permission.Id, Name = permission.Name
                        });
                    }
                    memberModel.TeamsMembership = new TeamsMembershipModel()
                    {
                        Value = item.TeamsMembership.Value,
                        Name  = item.TeamsMembership.Name.ToString()
                    };
                    viewModel.TeamMembers.Add(memberModel);
                }

                // Notes
                foreach (var item in entity.Content.Notes.ToList())
                {
                    var note = new NoteModel();
                    note.Id = item.Id;

                    var userProfile = new UserProfileViewModel();
                    userProfile.Id                = item.CreatedBy.Id;
                    userProfile.DisplayName       = item.CreatedBy.DisplayName;
                    userProfile.Mail              = item.CreatedBy.Fields.Mail;
                    userProfile.UserPrincipalName = item.CreatedBy.Fields.UserPrincipalName;
                    userProfile.UserRoles         = await _userProfileHelpers.RolesToViewModelAsync(item.CreatedBy.Fields.UserRoles, requestId);

                    note.CreatedBy       = userProfile;
                    note.NoteBody        = item.NoteBody;
                    note.CreatedDateTime = item.CreatedDateTime;

                    viewModel.Notes.Add(note);
                }

                // DocumentAttachments
                viewModel.DocumentAttachments = new List <DocumentAttachmentModel>();
                if (entity.DocumentAttachments != null)
                {
                    foreach (var itm in entity.DocumentAttachments)
                    {
                        var doc = new DocumentAttachmentModel();
                        doc.Id            = itm.Id ?? String.Empty;
                        doc.FileName      = itm.FileName ?? String.Empty;
                        doc.Note          = itm.Note ?? String.Empty;
                        doc.Tags          = itm.Tags ?? String.Empty;
                        doc.Category      = new CategoryModel();
                        doc.Category.Id   = itm.Category.Id;
                        doc.Category.Name = itm.Category.Name;
                        doc.DocumentUri   = itm.DocumentUri;

                        viewModel.DocumentAttachments.Add(doc);
                    }
                }

                return(viewModel);
            }
            catch (Exception ex)
            {
                // TODO: _logger.LogError("MapToViewModelAsync error: " + ex);
                throw new ResponseException($"RequestId: {requestId} - OpportunityToViewModelAsync oppId: {oppId} - failed to map opportunity: {ex}");
            }
        }
        public async Task <OpportunityViewModel> OpportunityToViewModelAsync(Opportunity entity, string requestId = "")
        {
            var oppId = entity.Id;

            try
            {
                //var entityDto = TinyMapper.Map<OpportunityViewModel>(entity);
                var viewModel = new OpportunityViewModel
                {
                    Id               = entity.Id,
                    DisplayName      = entity.DisplayName,
                    Reference        = entity.Reference,
                    Version          = entity.Version,
                    OpportunityState = OpportunityStateModel.FromValue(entity.Metadata.OpportunityState.Value),
                    DealSize         = entity.Metadata.DealSize,
                    AnnualRevenue    = entity.Metadata.AnnualRevenue,
                    OpenedDate       = entity.Metadata.OpenedDate,
                    //For DashBoard
                    TargetDate = entity.Metadata.TargetDate,
                    Industry   = new IndustryModel
                    {
                        Name = entity.Metadata.Industry.Name,
                        Id   = entity.Metadata.Industry.Id
                    },
                    Region = new RegionModel
                    {
                        Name = entity.Metadata.Region.Name,
                        Id   = entity.Metadata.Region.Id
                    },
                    Margin               = entity.Metadata.Margin,
                    Rate                 = entity.Metadata.Rate,
                    DebtRatio            = entity.Metadata.DebtRatio,
                    Purpose              = entity.Metadata.Purpose,
                    DisbursementSchedule = entity.Metadata.DisbursementSchedule,
                    CollateralAmount     = entity.Metadata.CollateralAmount,
                    Guarantees           = entity.Metadata.Guarantees,
                    RiskRating           = entity.Metadata.RiskRating,
                    OpportunityChannelId = entity.Metadata.OpportunityChannelId,
                    Customer             = new CustomerModel
                    {
                        DisplayName = entity.Metadata.Customer.DisplayName,
                        Id          = entity.Metadata.Customer.Id,
                        ReferenceId = entity.Metadata.Customer.ReferenceId
                    },
                    TeamMembers = new List <TeamMemberModel>(),
                    Notes       = new List <NoteModel>(),
                    Checklists  = new List <ChecklistModel>()
                };

                //DealType
                var dealTypeFlag = false;
                dealTypeFlag = entity.Content.DealType is null || entity.Content.DealType.Id is null;
                if (!dealTypeFlag)
                {
                    viewModel.DealType = await _templateHelpers.MapToViewModel(entity.Content.DealType);

                    //DealType Processes
                    var checklistPass = false;
                    foreach (var item in entity.Content.DealType.ProcessList)
                    {
                        if (item.ProcessType.ToLower() == "checklisttab" && checklistPass == false)
                        {
                            viewModel = await _checkListProcessService.MapToModelAsync(entity, viewModel, requestId);

                            checklistPass = true;
                        }
                        if (item.ProcessType.ToLower() == "feedbacktab")
                        {
                            viewModel = await customerFeedbackProcessService.MapToModelAsync(entity, viewModel, requestId);
                        }
                        if (item.ProcessType.ToLower() == "customerdecisiontab")
                        {
                            viewModel = await _customerDecisionProcessService.MapToModelAsync(entity, viewModel, requestId);
                        }
                        if (item.ProcessType.ToLower() == "proposalstatustab")
                        {
                            viewModel = await _proposalStatusProcessService.MapToModelAsync(entity, viewModel, requestId);
                        }
                    }
                }



                // TeamMembers
                foreach (var item in entity.Content.TeamMembers.ToList())
                {
                    var memberModel = new TeamMemberModel();
                    memberModel.AssignedRole = await _userProfileHelpers.RoleToViewModelAsync(item.AssignedRole, requestId);

                    memberModel.Id                = item.Id;
                    memberModel.DisplayName       = item.DisplayName;
                    memberModel.Mail              = item.Fields.Mail;
                    memberModel.UserPrincipalName = item.Fields.UserPrincipalName;
                    memberModel.Title             = item.Fields.Title ?? String.Empty;
                    memberModel.ProcessStep       = item.ProcessStep;

                    viewModel.TeamMembers.Add(memberModel);
                }

                // Notes
                foreach (var item in entity.Content.Notes.ToList())
                {
                    var note = new NoteModel();
                    note.Id = item.Id;

                    var userProfile = new UserProfileViewModel();
                    userProfile.Id                = item.CreatedBy.Id;
                    userProfile.DisplayName       = item.CreatedBy.DisplayName;
                    userProfile.Mail              = item.CreatedBy.Fields.Mail;
                    userProfile.UserPrincipalName = item.CreatedBy.Fields.UserPrincipalName;
                    userProfile.UserRoles         = await _userProfileHelpers.RolesToViewModelAsync(item.CreatedBy.Fields.UserRoles, requestId);

                    note.CreatedBy       = userProfile;
                    note.NoteBody        = item.NoteBody;
                    note.CreatedDateTime = item.CreatedDateTime;

                    viewModel.Notes.Add(note);
                }

                // DocumentAttachments
                viewModel.DocumentAttachments = new List <DocumentAttachmentModel>();
                if (entity.DocumentAttachments != null)
                {
                    foreach (var itm in entity.DocumentAttachments)
                    {
                        var doc = new DocumentAttachmentModel();
                        doc.Id            = itm.Id ?? String.Empty;
                        doc.FileName      = itm.FileName ?? String.Empty;
                        doc.Note          = itm.Note ?? String.Empty;
                        doc.Tags          = itm.Tags ?? String.Empty;
                        doc.Category      = new CategoryModel();
                        doc.Category.Id   = itm.Category.Id;
                        doc.Category.Name = itm.Category.Name;
                        doc.DocumentUri   = itm.DocumentUri;

                        viewModel.DocumentAttachments.Add(doc);
                    }
                }

                return(viewModel);
            }
            catch (Exception ex)
            {
                // TODO: _logger.LogError("MapToViewModelAsync error: " + ex);
                throw new ResponseException($"RequestId: {requestId} - OpportunityToViewModelAsync oppId: {oppId} - failed to map opportunity: {ex}");
            }
        }
Пример #4
0
 public static DocumentAttachmentViewModel CreateEditable(DocumentAttachmentModel documentModel)
 {
     return(new DocumentAttachmentViewModel(documentModel, false));
 }
Пример #5
0
 public static DocumentAttachmentViewModel CreateReadonly(DocumentAttachmentModel documentModel)
 {
     return(new DocumentAttachmentViewModel(documentModel, true));
 }
Пример #6
0
 private DocumentAttachmentViewModel(DocumentAttachmentModel documentModel, bool isReadonly) : base(documentModel, isReadonly)
 {
 }
Пример #7
0
        public async Task <OpportunityViewModel> OpportunityToViewModelAsync(Opportunity entity, string requestId = "")
        {
            var oppId = entity.Id;

            try
            {
                //var entityDto = TinyMapper.Map<OpportunityViewModel>(entity);
                var viewModel = new OpportunityViewModel
                {
                    Id               = entity.Id,
                    DisplayName      = entity.DisplayName,
                    Reference        = entity.Reference,
                    Version          = entity.Version,
                    OpportunityState = OpportunityStateModel.FromValue(entity.Metadata.OpportunityState.Value),
                    DealSize         = entity.Metadata.DealSize,
                    AnnualRevenue    = entity.Metadata.AnnualRevenue,
                    OpenedDate       = entity.Metadata.OpenedDate,
                    Industry         = new IndustryModel
                    {
                        Name = entity.Metadata.Industry.Name,
                        Id   = entity.Metadata.Industry.Id
                    },
                    Region = new RegionModel
                    {
                        Name = entity.Metadata.Region.Name,
                        Id   = entity.Metadata.Region.Id
                    },
                    Margin               = entity.Metadata.Margin,
                    Rate                 = entity.Metadata.Rate,
                    DebtRatio            = entity.Metadata.DebtRatio,
                    Purpose              = entity.Metadata.Purpose,
                    DisbursementSchedule = entity.Metadata.DisbursementSchedule,
                    CollateralAmount     = entity.Metadata.CollateralAmount,
                    Guarantees           = entity.Metadata.Guarantees,
                    RiskRating           = entity.Metadata.RiskRating,
                    OpportunityChannelId = entity.Metadata.OpportunityChannelId,
                    Customer             = new CustomerModel
                    {
                        DisplayName = entity.Metadata.Customer.DisplayName,
                        Id          = entity.Metadata.Customer.Id,
                        ReferenceId = entity.Metadata.Customer.ReferenceId
                    },
                    TeamMembers      = new List <TeamMemberModel>(),
                    Notes            = new List <NoteModel>(),
                    Checklists       = new List <ChecklistModel>(),
                    CustomerDecision = new CustomerDecisionModel
                    {
                        Id            = entity.Content.CustomerDecision.Id,
                        Approved      = entity.Content.CustomerDecision.Approved,
                        ApprovedDate  = entity.Content.CustomerDecision.ApprovedDate,
                        LoanDisbursed = entity.Content.CustomerDecision.LoanDisbursed
                    }
                };

                viewModel.ProposalDocument               = new ProposalDocumentModel();
                viewModel.ProposalDocument.Id            = entity.Content.ProposalDocument.Id;
                viewModel.ProposalDocument.DisplayName   = entity.Content.ProposalDocument.DisplayName;
                viewModel.ProposalDocument.Reference     = entity.Content.ProposalDocument.Reference;
                viewModel.ProposalDocument.DocumentUri   = entity.Content.ProposalDocument.Metadata.DocumentUri;
                viewModel.ProposalDocument.Category      = new CategoryModel();
                viewModel.ProposalDocument.Category.Id   = entity.Content.ProposalDocument.Metadata.Category.Id;
                viewModel.ProposalDocument.Category.Name = entity.Content.ProposalDocument.Metadata.Category.Name;
                viewModel.ProposalDocument.Content       = new ProposalDocumentContentModel();
                viewModel.ProposalDocument.Content.ProposalSectionList = new List <DocumentSectionModel>();
                viewModel.ProposalDocument.Notes = new List <NoteModel>();

                viewModel.ProposalDocument.Tags    = entity.Content.ProposalDocument.Metadata.Tags;
                viewModel.ProposalDocument.Version = entity.Content.ProposalDocument.Version;


                // Checklists
                foreach (var item in entity.Content.Checklists)
                {
                    var checklistTasks = new List <ChecklistTaskModel>();
                    foreach (var subitem in item.ChecklistTaskList)
                    {
                        var checklistItem = new ChecklistTaskModel
                        {
                            Id            = subitem.Id,
                            ChecklistItem = subitem.ChecklistItem,
                            Completed     = subitem.Completed,
                            FileUri       = subitem.FileUri
                        };
                        checklistTasks.Add(checklistItem);
                    }

                    var checklistModel = new ChecklistModel
                    {
                        Id = item.Id,
                        ChecklistStatus   = item.ChecklistStatus,
                        ChecklistTaskList = checklistTasks,
                        ChecklistChannel  = item.ChecklistChannel
                    };
                    viewModel.Checklists.Add(checklistModel);
                }


                // TeamMembers
                foreach (var item in entity.Content.TeamMembers.ToList())
                {
                    var memberModel = new TeamMemberModel();
                    memberModel.Status       = item.Status;
                    memberModel.AssignedRole = await _userProfileHelpers.RoleToViewModelAsync(item.AssignedRole, requestId);

                    memberModel.Id                = item.Id;
                    memberModel.DisplayName       = item.DisplayName;
                    memberModel.Mail              = item.Fields.Mail;
                    memberModel.UserPrincipalName = item.Fields.UserPrincipalName;
                    memberModel.Title             = item.Fields.Title ?? String.Empty;

                    viewModel.TeamMembers.Add(memberModel);
                }


                // Notes
                foreach (var item in entity.Content.Notes.ToList())
                {
                    var note = new NoteModel();
                    note.Id = item.Id;

                    var userProfile = new UserProfileViewModel();
                    userProfile.Id                = item.CreatedBy.Id;
                    userProfile.DisplayName       = item.CreatedBy.DisplayName;
                    userProfile.Mail              = item.CreatedBy.Fields.Mail;
                    userProfile.UserPrincipalName = item.CreatedBy.Fields.UserPrincipalName;
                    userProfile.UserRoles         = await _userProfileHelpers.RolesToViewModelAsync(item.CreatedBy.Fields.UserRoles, requestId);

                    note.CreatedBy       = userProfile;
                    note.NoteBody        = item.NoteBody;
                    note.CreatedDateTime = item.CreatedDateTime;

                    viewModel.Notes.Add(note);
                }


                // ProposalDocument Notes
                foreach (var item in entity.Content.ProposalDocument.Metadata.Notes.ToList())
                {
                    var docNote = new NoteModel();

                    docNote.Id = item.Id;
                    docNote.CreatedDateTime = item.CreatedDateTime;
                    docNote.NoteBody        = item.NoteBody;
                    docNote.CreatedBy       = new UserProfileViewModel
                    {
                        Id                = item.CreatedBy.Id,
                        DisplayName       = item.CreatedBy.DisplayName,
                        Mail              = item.CreatedBy.Fields.Mail,
                        UserPrincipalName = item.CreatedBy.Fields.UserPrincipalName,
                        UserRoles         = await _userProfileHelpers.RolesToViewModelAsync(item.CreatedBy.Fields.UserRoles, requestId)
                    };

                    viewModel.ProposalDocument.Notes.Add(docNote);
                }


                // ProposalDocument ProposalSectionList
                foreach (var item in entity.Content.ProposalDocument.Content.ProposalSectionList.ToList())
                {
                    if (!String.IsNullOrEmpty(item.Id))
                    {
                        var docSectionModel = new DocumentSectionModel();
                        docSectionModel.Id                   = item.Id;
                        docSectionModel.DisplayName          = item.DisplayName;
                        docSectionModel.LastModifiedDateTime = item.LastModifiedDateTime;
                        docSectionModel.Owner                = new UserProfileViewModel();
                        if (item.Owner != null)
                        {
                            docSectionModel.Owner.Id          = item.Owner.Id ?? String.Empty;
                            docSectionModel.Owner.DisplayName = item.Owner.DisplayName ?? String.Empty;
                            if (item.Owner.Fields != null)
                            {
                                docSectionModel.Owner.Mail = item.Owner.Fields.Mail ?? String.Empty;
                                docSectionModel.Owner.UserPrincipalName = item.Owner.Fields.UserPrincipalName ?? String.Empty;
                                docSectionModel.Owner.UserRoles         = new List <RoleModel>();

                                if (item.Owner.Fields.UserRoles != null)
                                {
                                    docSectionModel.Owner.UserRoles = await _userProfileHelpers.RolesToViewModelAsync(item.Owner.Fields.UserRoles, requestId);
                                }
                            }
                            else
                            {
                                docSectionModel.Owner.Mail = String.Empty;
                                docSectionModel.Owner.UserPrincipalName = String.Empty;
                                docSectionModel.Owner.UserRoles         = new List <RoleModel>();

                                if (item.Owner.Fields.UserRoles != null)
                                {
                                    docSectionModel.Owner.UserRoles = await _userProfileHelpers.RolesToViewModelAsync(item.Owner.Fields.UserRoles, requestId);
                                }
                            }
                        }

                        docSectionModel.SectionStatus = item.SectionStatus;
                        docSectionModel.SubSectionId  = item.SubSectionId;
                        docSectionModel.AssignedTo    = new UserProfileViewModel();
                        if (item.AssignedTo != null)
                        {
                            docSectionModel.AssignedTo.Id                = item.AssignedTo.Id;
                            docSectionModel.AssignedTo.DisplayName       = item.AssignedTo.DisplayName;
                            docSectionModel.AssignedTo.Mail              = item.AssignedTo.Fields.Mail;
                            docSectionModel.AssignedTo.Title             = item.AssignedTo.Fields.Title;
                            docSectionModel.AssignedTo.UserPrincipalName = item.AssignedTo.Fields.UserPrincipalName;
                            // TODO: Not including role info since it is not relevant but if needed it needs to be set here
                        }
                        docSectionModel.Task = item.Task;

                        viewModel.ProposalDocument.Content.ProposalSectionList.Add(docSectionModel);
                    }
                }

                // DocumentAttachments
                viewModel.DocumentAttachments = new List <DocumentAttachmentModel>();
                if (entity.DocumentAttachments != null)
                {
                    foreach (var itm in entity.DocumentAttachments)
                    {
                        var doc = new DocumentAttachmentModel();
                        doc.Id            = itm.Id ?? String.Empty;
                        doc.FileName      = itm.FileName ?? String.Empty;
                        doc.Note          = itm.Note ?? String.Empty;
                        doc.Tags          = itm.Tags ?? String.Empty;
                        doc.Category      = new CategoryModel();
                        doc.Category.Id   = itm.Category.Id;
                        doc.Category.Name = itm.Category.Name;
                        doc.DocumentUri   = itm.DocumentUri;

                        viewModel.DocumentAttachments.Add(doc);
                    }
                }

                return(viewModel);
            }
            catch (Exception ex)
            {
                // TODO: _logger.LogError("MapToViewModelAsync error: " + ex);
                throw new ResponseException($"RequestId: {requestId} - OpportunityToViewModelAsync oppId: {oppId} - failed to map opportunity: {ex}");
            }
        }