public IActionResult Details(int id) { CustomerExpectation customerExpectation = _customerExpectationService.GetCustomerExpectationById(id); CustomerExpectationDisplayModel model = CustomerExpectationDisplayModel.GenerateModel(customerExpectation); return(View(model)); }
public static CustomerExpectationDisplayModel GenerateModelForList(CustomerExpectation customerExpectation) { CustomerExpectationDisplayModel model = new CustomerExpectationDisplayModel() { CEID = customerExpectation.Id, CustomerName = customerExpectation.Customer.CustomerName, IDNumber = customerExpectation.Customer.IDNumber, PhoneNumber = customerExpectation.Customer.PhoneNumber, CustomerCreatedOn = customerExpectation.Customer.CreatedOn, customerType = (CustomerType)customerExpectation.CustomerTypeId, CreatedOn = customerExpectation.CreatedOn, ExpectedLoanAmount = customerExpectation.ExpectedLoanAmount, ExpectedLoanTime = customerExpectation.ExpectedLoanTime, //CompanyName = (CustomerType)customerExpectation.CustomerTypeId == CustomerType.自雇 ? customerExpectation.CustomerSelfEmployeds.First().CompanyName : customerExpectation.CustomerHireds.First().CompanyName, HavingCreditCardCarLoan = customerExpectation.HavingCreditCardCarLoan, HavingRealEstate = customerExpectation.HavingRealEstate, HavingLifeInsurance = customerExpectation.HavingLifeInsurance, }; return(model); }
public IActionResult CreateAll(InputAllDataModel model) { if (!model.AgreeToInformationAuthorization || !model.AgreeToServiceAuthorization) { return(View("CreateErr", new ErrorViewModel() { RequestId = "您没有同意服务和信息授权,请退出。" })); } //if (!ModelState.IsValid) //{ // // work with the model // return View("CreateErr", new ErrorViewModel() { RequestId = "数据缺失请回退。" }); //} if (model.ExpectedLoanTime == null) { return(View("CreateErr", new ErrorViewModel() { RequestId = "期望放款时间缺失请回退。" })); } DateTime dateTime = DateTime.Now; Customer customer = _customerService.GetCustomerByIDNumber(model.IDNumber); if (customer == null) { customer = new Customer() { Avatar = "", CreatedOn = dateTime, CustomerName = model.CustomerName, Fever = 0, IDNumber = model.IDNumber, IsDeleted = false, LoginName = model.PhoneNumber, CPassword = "******", PhoneNumber = model.PhoneNumber, Salt = "0000" }; _customerService.InsertCustomer(customer); } CustomerExpectation customerExpectation = new CustomerExpectation() { CreatedOn = dateTime, CustomerId = customer.Id, CustomerTypeId = (int)model.customerType, ExpectedLoanAmount = model.ExpectedLoanAmount, ExpectedLoanTime = model.ExpectedLoanTime, WorkingAddress = model.WorkingAddress, HavingCreditCardCarLoan = model.HavingCreditCardCarLoan, HavingLifeInsurance = model.HavingLifeInsurance, HavingRealEstate = model.HavingRealEstate }; _customerExpectationService.InsertCustomerExpectation(customerExpectation); if (model.HavingCreditCardCarLoan) { CCreditCardCarLoan cCreditCardCarLoan = new CCreditCardCarLoan() { CustomerExpectationId = customerExpectation.Id, CreatedOn = dateTime, MonthlyAmount = model.CCLMonthlyAmount, NumberOfRepaymentsCC = model.NumberOfRepaymentsCC }; _customerExpectationService.InsertCCreditCardCarLoan(cCreditCardCarLoan); } if (model.HavingLifeInsurance) { List <CLifeInsurance> cLives = new List <CLifeInsurance>(); CLifeInsurance cLifeInsurance0 = new CLifeInsurance() { CustomerExpectationId = customerExpectation.Id, CreatedOn = dateTime, AnnualPremium = model.AnnualPremium0, EarliestEffectiveTime = model.EarliestEffectiveTime0, LifeInsuranceCompany = model.LifeInsuranceCompany0 }; cLives.Add(cLifeInsurance0); if (model.AnnualPremium1 > 0.0M) { CLifeInsurance cLifeInsurance1 = new CLifeInsurance() { CustomerExpectationId = customerExpectation.Id, CreatedOn = dateTime, AnnualPremium = model.AnnualPremium1, EarliestEffectiveTime = model.EarliestEffectiveTime1, LifeInsuranceCompany = model.LifeInsuranceCompany1 }; cLives.Add(cLifeInsurance1); } if (model.AnnualPremium2 > 0.0M) { CLifeInsurance cLifeInsurance2 = new CLifeInsurance() { CustomerExpectationId = customerExpectation.Id, CreatedOn = dateTime, AnnualPremium = model.AnnualPremium2, EarliestEffectiveTime = model.EarliestEffectiveTime2, LifeInsuranceCompany = model.LifeInsuranceCompany2 }; cLives.Add(cLifeInsurance2); } _customerExpectationService.InsertCLifeInsurances(cLives); } if (model.HavingRealEstate) { bool needRepay = true; if (model.realEstateLoanType == Models.Enum.RealEstateLoanType.全款) { needRepay = false; } CRealEstate cRealEstate = new CRealEstate() { CustomerExpectationId = customerExpectation.Id, BankName = model.BankName, ConstructionArea = model.ConstructionArea, CreatedOn = dateTime, LoanTypeId = (int)model.realEstateLoanType, MonthlyPayment = needRepay?model.MonthlyPayment:0, NumberOfRepayments = needRepay?model.NumberOfRepayments:0, PropertyNatureId = (int)model.realEstatePropertyNature, RealEstateAddress = model.RealEstateAddress, RealEstateValue = model.RealEstateValue }; if (model.realEstateLoanType == Models.Enum.RealEstateLoanType.全款) { cRealEstate.BankName = ""; cRealEstate.MonthlyPayment = 0; cRealEstate.NumberOfRepayments = 0; } _customerExpectationService.InsertCRealEstate(cRealEstate); } if (model.customerType == Models.Enum.CustomerType.班) { CustomerHired customerHired = new CustomerHired() { CustomerExpectationId = customerExpectation.Id, CompanyName = model.CompanyName, CreatedOn = dateTime, HavingSIHF = model.HavingSIHF, HousingFundBase = model.HousingFundBase, SalaryAfterTax = model.SalaryAfterTax, SocialInsuranceBase = model.SocialInsuranceBase }; _customerExpectationService.InsertCustomerHired(customerHired); } else if (model.customerType == Models.Enum.CustomerType.自雇) { CustomerSelfEmployed customerSelfEmployed = new CustomerSelfEmployed() { CustomerExpectationId = customerExpectation.Id, CreatedOn = dateTime, CompanyName = model.CompanyName, AnnualTaxAmount = model.AnnualTaxAmount, AnnualTurnover = model.AnnualTurnover, AnnualVATInvoiceAmount = model.AnnualVATInvoiceAmount }; _customerExpectationService.InsertCustomerSelfEmployed(customerSelfEmployed); } return(Redirect("http://u.vivatech.cn/h/6601")); }
public static CustomerExpectationDisplayModel GenerateModel(CustomerExpectation customerExpectation) { CustomerExpectationDisplayModel model = new CustomerExpectationDisplayModel() { CEID = customerExpectation.Id, CustomerName = customerExpectation.Customer.CustomerName, IDNumber = customerExpectation.Customer.IDNumber, PhoneNumber = customerExpectation.Customer.PhoneNumber, CustomerCreatedOn = customerExpectation.Customer.CreatedOn, customerType = (CustomerType)customerExpectation.CustomerTypeId, WorkingAddress = customerExpectation.WorkingAddress, CreatedOn = customerExpectation.CreatedOn, ExpectedLoanAmount = customerExpectation.ExpectedLoanAmount, ExpectedLoanTime = customerExpectation.ExpectedLoanTime, //CompanyName = (CustomerType)customerExpectation.CustomerTypeId == CustomerType.自雇 ? customerExpectation.CustomerSelfEmployeds.First().CompanyName : customerExpectation.CustomerHireds.First().CompanyName, HavingCreditCardCarLoan = customerExpectation.HavingCreditCardCarLoan, HavingRealEstate = customerExpectation.HavingRealEstate, HavingLifeInsurance = customerExpectation.HavingLifeInsurance, }; if (model.customerType == CustomerType.班) { var chs = customerExpectation.CustomerHireds; var customerHired = chs.First(); model.CompanyName = customerHired.CompanyName; model.SalaryAfterTax = customerHired.SalaryAfterTax; if (model.HavingSIHF) { model.SocialInsuranceBase = customerHired.SocialInsuranceBase; model.HousingFundBase = customerHired.HousingFundBase; } } else if (model.customerType == CustomerType.自雇) { var customerSelfEmployed = customerExpectation.CustomerSelfEmployeds.First(); model.AnnualTaxAmount = customerSelfEmployed.AnnualTaxAmount; model.AnnualTurnover = customerSelfEmployed.AnnualTurnover; model.AnnualVATInvoiceAmount = customerSelfEmployed.AnnualVATInvoiceAmount; } if (model.HavingLifeInsurance) { var lfis = customerExpectation.CLifeInsurances; var ls = lfis.ToList(); if (ls.First() != null) { var l = lfis.First(); model.AnnualPremium0 = l.AnnualPremium; model.EarliestEffectiveTime0 = l.EarliestEffectiveTime; model.LifeInsuranceCompany0 = l.LifeInsuranceCompany; } try { { var l = ls[1]; model.AnnualPremium1 = l.AnnualPremium; model.EarliestEffectiveTime1 = l.EarliestEffectiveTime; model.LifeInsuranceCompany1 = l.LifeInsuranceCompany; } { var l = ls[2]; model.AnnualPremium2 = l.AnnualPremium; model.EarliestEffectiveTime2 = l.EarliestEffectiveTime; model.LifeInsuranceCompany2 = l.LifeInsuranceCompany; } } catch (Exception ex) { } } if (model.HavingCreditCardCarLoan) { var ccc = customerExpectation.CCreditCardCarLoans.First(); model.NumberOfRepaymentsCC = ccc.NumberOfRepaymentsCC; model.CCLMonthlyAmount = ccc.MonthlyAmount; } if (model.HavingRealEstate) { var re = customerExpectation.CRealEstates.First(); model.RealEstateAddress = re.RealEstateAddress; model.realEstateLoanType = (RealEstateLoanType)re.LoanTypeId; model.realEstatePropertyNature = (RealEstatePropertyNature)re.PropertyNatureId; model.RealEstateValue = re.RealEstateValue; model.BankName = re.BankName; model.NumberOfRepayments = re.NumberOfRepayments; model.ConstructionArea = re.ConstructionArea; model.MonthlyPayment = re.MonthlyPayment; } return(model); }
public CustomerExpectation InsertCustomerExpectation(CustomerExpectation customerExpectation) { _customerExpectationRepository.Insert(customerExpectation); _mysqlContext.SaveChanges(); return(customerExpectation); }