示例#1
0
        public async Task <ProcessTypeListViewModel> GetAllAsync(string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - GetAllAsync called.");

            try
            {
                var listItems = (await _processRepository.GetAllAsync(requestId)).ToList();
                Guard.Against.Null(listItems, nameof(listItems), requestId);

                var processTypeListViewModel = new ProcessTypeListViewModel();
                foreach (var item in listItems)
                {
                    processTypeListViewModel.ItemsList.Add(MapToProcessViewModel(item));
                }

                if (processTypeListViewModel.ItemsList.Count == 0)
                {
                    _logger.LogWarning($"RequestId: {requestId} - GetAllAsync no items found");
                    throw new NoItemsFound($"RequestId: {requestId} - Method name: GetAllAsync - No Items Found");
                }

                return(processTypeListViewModel);
            }
            catch (Exception ex)
            {
                _logger.LogError($"RequestId: {requestId} - GetAllAsync Service Exception: {ex}");
                throw new ResponseException($"RequestId: {requestId} - GetAllAsync Service Exception: {ex}");
            }
        }
        public async Task <Opportunity> CreateWorkflowAsync(Opportunity opportunity, string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - CreateDashBoardEntryAsync called.");
            try
            {
                var targetDate = opportunity.Metadata.Fields.ToList().Find(x => x.DisplayName.Equals("Target Date", StringComparison.OrdinalIgnoreCase))?.Values;
                var openedDate = opportunity.Metadata.Fields.ToList().Find(x => x.DisplayName.Equals("Opened Date", StringComparison.OrdinalIgnoreCase))?.Values;

                if (targetDate != null && openedDate != null)
                {
                    var entity = new Dashboard();
                    entity.CustomerName    = opportunity.Metadata.Customer.DisplayName;
                    entity.Status          = opportunity.Metadata.OpportunityState.Name;
                    entity.StartDate       = openedDate ?? String.Empty;
                    entity.OpportunityName = opportunity.DisplayName;
                    entity.OpportunityId   = opportunity.Id;
                    entity.Id                      = String.Empty;
                    entity.TotalNoOfDays           = 0;
                    entity.ProcessList             = new List <DashboardProcessList>();
                    entity.ProcessEndDateList      = new List <DashboradProcessEndDateList>();
                    entity.ProcessLoanOfficerNames = new List <DashboardLoanOfficers>();

                    var processList = (await _processRepository.GetAllAsync(requestId)).ToList().Where(x => x.ProcessType.Equals("checklisttab", StringComparison.OrdinalIgnoreCase));

                    foreach (var process in processList)
                    {
                        entity.ProcessList.Add(new DashboardProcessList
                        {
                            ProcessName      = process.Channel.ToLower(),
                            ProcessEndDate   = string.Empty,
                            ProcessStartDate = string.Empty,
                            NoOfDays         = 0
                        });

                        entity.ProcessEndDateList.Add(new DashboradProcessEndDateList
                        {
                            Process = process.Channel.ToLower() + "enddate",
                            EndDate = string.Empty
                        });
                    }

                    var loanOfficerAdgroup = opportunity.Content.TeamMembers.FirstOrDefault(mem => mem.Fields.Permissions.Any(per => per.Name.Equals("opportunity_readwrite_dealtype", StringComparison.OrdinalIgnoreCase)));
                    entity.ProcessLoanOfficerNames.Add(new DashboardLoanOfficers
                    {
                        AdGroupName = loanOfficerAdgroup != null ? loanOfficerAdgroup.RoleName : string.Empty,
                        OfficerName = loanOfficerAdgroup != null ? loanOfficerAdgroup.DisplayName : string.Empty
                    });

                    await _dashboardRepository.CreateOpportunityAsync(entity, requestId);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"RequestId: {requestId} - CreateDashBoardEntryAsync Service Exception: {ex}");
            }

            return(opportunity);
        }
示例#3
0
        public async Task <ProcessTypeListViewModel> GetAllAsync(string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - GetAllAsync called.");

            try
            {
                var processTypeListViewModel = new ProcessTypeListViewModel();
                processTypeListViewModel.ItemsList = (await processRepository.GetAllAsync(requestId)).Select(item => MapToProcessViewModel(item)).ToList();

                if (processTypeListViewModel.ItemsList.Count == 0)
                {
                    _logger.LogWarning($"RequestId: {requestId} - GetAllAsync no items found");
                    throw new NoItemsFound($"RequestId: {requestId} - Method name: GetAllAsync - No Items Found");
                }

                return(processTypeListViewModel);
            }
            catch (Exception ex)
            {
                _logger.LogError($"RequestId: {requestId} - GetAllAsync Service Exception: {ex}");
                throw new ResponseException($"RequestId: {requestId} - GetAllAsync Service Exception: {ex}");
            }
        }
        public async Task Execute(IJobExecutionContext context)
        {
            Console.WriteLine("Hello from the DataRetrievalJob");
            try
            {
                var itemProcessesIEnum = await itemProcessRepository.GetAllAsync();

                List <ItemProcess> itemProcesses = itemProcessesIEnum.ToList();

                // instead of directly processing them, maybe trigger event or use mediator
                Task[] runProccessTasks = new Task[itemProcesses.Count];
                for (int i = 0; i < itemProcesses.Count; i++)
                {
                    runProccessTasks[i] = RunProcessAsync(itemProcesses[i]);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }