public async Task <string> Create([FromBody] LoanApplicationDto loanApplicationDto) { var newApplicationNumber = await bus.Send(new SubmitLoanApplication.Command { LoanApplication = loanApplicationDto, CurrentUser = User }); return(newApplicationNumber); }
public async Task <string> CreateLoanApplication(LoanApplicationDto loanApplicationDto, ClaimsPrincipal principal) { var user = await GetOperatorByLogin(principal.Identity.Name); var application = new LoanApplication { Number = GenerateLoanApplicationNumber(), Status = LoanApplicationStatus.New, Customer = new Customer { NationalIdentifier = loanApplicationDto.CustomerNationalIdentifier, FirstName = loanApplicationDto.CustomerFirstName, LastName = loanApplicationDto.CustomerLastName, Birthdate = loanApplicationDto.CustomerBirthdate, MonthlyIncome = loanApplicationDto.CustomerMonthlyIncome, Address = new Address { Country = loanApplicationDto.CustomerAddress.Country, City = loanApplicationDto.CustomerAddress.City, ZipCode = loanApplicationDto.CustomerAddress.ZipCode, Street = loanApplicationDto.CustomerAddress.Street } }, Property = new Property { Value = loanApplicationDto.PropertyValue, Address = new Address { Country = loanApplicationDto.PropertyAddress.Country, City = loanApplicationDto.PropertyAddress.City, ZipCode = loanApplicationDto.PropertyAddress.ZipCode, Street = loanApplicationDto.PropertyAddress.Street } }, LoanAmount = loanApplicationDto.LoanAmount, LoanNumberOfYears = loanApplicationDto.LoanNumberOfYears, InterestRate = loanApplicationDto.InterestRate, RegisteredBy = user, RegistrationDate = DateTime.Now }; validationService.ValidateLoanApplication(application); await loanApplicationRepository.Create(application); await unitOfWork.CommitChanges(); return(application.Number); }
public string SubmitLoanApplication(LoanApplicationDto loanApplicationDto, ClaimsPrincipal principal) { var user = operators.WithLogin(principal.Identity.Name); var application = new DomainModel.LoanApplication ( Guid.NewGuid().ToString(), new Customer ( new NationalIdentifier(loanApplicationDto.CustomerNationalIdentifier), new Name(loanApplicationDto.CustomerFirstName, loanApplicationDto.CustomerLastName), loanApplicationDto.CustomerBirthdate, new MonetaryAmount(loanApplicationDto.CustomerMonthlyIncome), new Address ( loanApplicationDto.CustomerAddress.Country, loanApplicationDto.CustomerAddress.ZipCode, loanApplicationDto.CustomerAddress.City, loanApplicationDto.CustomerAddress.Street ) ), new Property ( new MonetaryAmount(loanApplicationDto.PropertyValue), new Address ( loanApplicationDto.PropertyAddress.Country, loanApplicationDto.PropertyAddress.ZipCode, loanApplicationDto.PropertyAddress.City, loanApplicationDto.PropertyAddress.Street ) ), new Loan ( new MonetaryAmount(loanApplicationDto.LoanAmount), loanApplicationDto.LoanNumberOfYears, new Percent(loanApplicationDto.InterestRate) ), user ); loanApplications.Add(application); unitOfWork.CommitChanges(); return(application.Number); }
private ResultDto InsertupdateLoanApplication(LoanApplicationDto LoanApplication) { ResultDto resultDto = new ResultDto(); LoanApplication.LoanType = "G"; LoanApplication.Mode = 1045; LoanApplication.MemberID = 1; string obectName = "Loan Application"; try { ObjectParameter paramLoanMasterID = new ObjectParameter("LoanMasterID", LoanApplication.LoanMasterId); ObjectParameter paramloanCode = new ObjectParameter("LoanCode", string.Empty); int count = _dbContext.uspLoanApplicationInsertUpdate(paramLoanMasterID, paramloanCode, LoanApplication.LoanType, LoanApplication.MemberID, LoanApplication.GroupID, LoanApplication.LoanApplicationDate, LoanApplication.LoanPurpose, LoanApplication.FundSourceId, LoanApplication.ProjectID, LoanApplication.LoanAmountApplied, LoanApplication.NoofInstallmentsProposed, LoanApplication.Mode, LoanApplication.UserID, LoanApplication.InterestMasterID); resultDto.ObjectId = (int)paramLoanMasterID.Value; resultDto.ObjectCode = string.IsNullOrEmpty((string)paramloanCode.Value) ? LoanApplication.LoanCode : (string)paramloanCode.Value; if (resultDto.ObjectId > 0) { resultDto.Message = string.Format("{0} details saved successfully with code : {1}", obectName, resultDto.ObjectCode); } else if (resultDto.ObjectId == -1) { resultDto.Message = string.Format("Error occured while generating {0} code", obectName); } else { resultDto.Message = string.Format("Error occured while saving {0} details", obectName); } } catch (Exception) { resultDto.Message = string.Format("Service layer error occured while saving the {0} details", obectName); resultDto.ObjectId = -98; } return(resultDto); }
public async Task <LoanApplicationDto> Create([FromBody] LoanApplicationDto loanApplicationDto) { var newApplicationNumber = await loanApplicationService.CreateLoanApplication(loanApplicationDto, User); return(await loanApplicationService.GetLoanApplication(newApplicationNumber)); }
public ResultDto Update(LoanApplicationDto LoanApplication) { return(InsertupdateLoanApplication(LoanApplication)); }