public CashFlowCalculation GetCashFlowData(int clientId, int planId, int riskProfileId) { _clientId = clientId; _planId = planId; _riskProfileId = riskProfileId; ClientPersonalInfo clientPersonalInfo = new ClientPersonalInfo(); PersonalInformation personalInfo = clientPersonalInfo.Get(clientId); fillPersonalData(personalInfo); _riskProfileInfo = new RiskProfileInfo(); PlannerAssumption plannerAssumption = new PlannerAssumptionInfo().GetAll(_planId); if (plannerAssumption != null) { fillCashFlowFromPlannerAssumption(plannerAssumption); } IList <Income> incomes = new IncomeInfo().GetAll(_planId); IList <Expenses> expenses = new ExpensesInfo().GetAll(_planId); IList <Loan> loans = new LoanInfo().GetAll(_planId); IList <Goals> goals = new GoalsInfo().GetAll(_planId); fillCashFlowFromIncomes(incomes); fillCashFlowFromExpenses(expenses); fillCashFlowFromLoans(loans); fillCashFlowFromGoals(goals); return(_cashFlow); }
public async Task <IActionResult> Index(IndexModel model, string submit, ClientPersonalInfo clientPersonalInfo, string regionWebServiceListName, string[] orgs) { IndexModel.SubmitType submitType = Enum.IsDefined(typeof(IndexModel.SubmitType), submit) ? (IndexModel.SubmitType)Enum.Parse(typeof(IndexModel.SubmitType), submit) : IndexModel.SubmitType.Null; if (!int.TryParse(Request.Cookies["ClientTimeZone"], out int clientTimeZone)) { submitType = IndexModel.SubmitType.Null; model.ErrorMessage = "Ошибка определения часового пояса на клиентской машине"; } model.ClientPersonalInfo = clientPersonalInfo ?? new ClientPersonalInfo(); ViewData["RequestCreditHistoryButtonDisabled"] = "style=\"display: none\""; ViewData["orgs"] = Organization.OrganizationsByLogin(User.Identity.Name, orgs); switch (submitType) { case IndexModel.SubmitType.Null: break; case IndexModel.SubmitType.GetFrom1C: if ((model.Account1CCode ?? default) == default) { break; } ModelState.Clear(); try { model = await NBCHRequest.GetDataFrom1CAsync(_Service1C, model.Account1CCode, _Secret1Cs, regionWebServiceListName, _Configuration); ViewData["RequestCreditHistoryButtonDisabled"] = ""; } catch (Exception exception) { _Logger.LogError( exception, "Ошибка получения данных из 1С. Пользователь: {login}, данные запроса: {model}, регион {region}, ошибка: {exceptionMessage}.", HelperASP.Login(User), model, regionWebServiceListName, exception.Message); model.ErrorMessage = exception.InnerException != default ? model.ErrorMessage += Environment.NewLine + exception.InnerException.Message : exception.Message; } break; case IndexModel.SubmitType.GetCH: Report report = new Report(); model.ClientTimeZone = clientTimeZone; try { report = await NBCHRequest.GetCreditHistoryAsync(_ServiceNBCHsoap, model, SecretNBCH.GetSecretNBCH(_Configuration, model.InquiryReq.ConsentReq.reportUser), _Logger); } catch (EndpointNotFoundException) { report.ErrorMessage = "Не удалось подключиться к службе NBCH (запрос данных из НБКИ)."; _Logger.LogError(report.ErrorMessage); } catch (Exception exception) { report.ErrorMessage = exception.ToString(); _Logger.LogError( exception, "Ошибка получения данных из НБКИ. Пользователь: {login}, данные запроса: {model}, ошибка: {exceptionMessage}.", HelperASP.Login(User), model, exception.Message); } model.AccountReply = report.AccountReply; model.Calc = report.calc; model.ErrorMessage = report.ErrorMessage; break; default: break; } ViewData["ReportDate"] = model?.Calc?.ReportDate ?? default; model.RegionsWebServiceListName = Secret1C.GetRegions(_Secret1Cs, regionWebServiceListName); Response.Cookies.Append(Startup.WebService1CRegion, regionWebServiceListName); return(View(model)); }