private void SendDelinquentPaymentNotification(LoanPayment payment, Client client) { mailService.SendMessage( SendDelinquentPaymentNotificationSubject, String.Format(SendDelinquentPaymentNotificationBody, client.FirstName, payment.Amount), client.Email); }
public void ConfirmClient(Client client) { Contract.Requires<ArgumentNullException>(client.IsNotNull()); client.IsConfirmed = true; this.gangsterBankUnitOfWork.ClientsRepository.CreateOrUpdate(client); this.mailService.SendMessage(EmailTemplateType.ApproveUser, client); }
public void CreateLoanRequest(Client client, LoanProduct loanProduct, decimal amount, int months) { Contract.Requires<ArgumentNullException>(client.IsNotNull()); Contract.Requires<ArgumentNullException>(loanProduct.IsNotNull()); VerifyWorkFlow(client, loanProduct); LoanRequest loanRequest = LoanRequest.Create(client, loanProduct, amount, months); this.TryApproveAndTakeLoanOnCreation(loanRequest); this.gangsterBankUnitOfWork.LoanRequestsRepository.CreateOrUpdate(loanRequest); }
public void Deposit(Client client, decimal amount) { Contract.Requires<ArgumentNullException>(client.IsNotNull()); Contract.Requires<ArgumentOutOfRangeException>(amount > 0); this.CreateNewPayment(client, amount, PaymentType.Debit); amount = this.PayLoanPayments(client, amount); CheckTakenLoansStatus(client); client.PrimaryAccount.Amount += amount; this.gangsterBankUnitOfWork.ClientsRepository.CreateOrUpdate(client); this.mailService.SendMessage(EmailTemplateType.Deposit, client, amount.ToString("C0")); }
public void Withdraw(Client client, decimal amount) { Contract.Requires<ArgumentNullException>(client.IsNotNull()); Contract.Requires<ArgumentOutOfRangeException>(amount > 0); if (client.PrimaryAccount.Amount < amount) { throw new ApplicationException("Not enough money"); } this.CreateNewPayment(client, amount, PaymentType.Credit); client.PrimaryAccount.Amount -= amount; this.gangsterBankUnitOfWork.ClientsRepository.CreateOrUpdate(client); this.mailService.SendMessage(EmailTemplateType.Withdraw, client, amount.ToString("C0")); }
private void ProceedPayment(LoanPayment payment, DateTime date, Client client) { var paymentDate = payment.Date; if (paymentDate < date) { this.SendDelinquentPaymentNotification(payment, client); } else if (paymentDate == date) { this.SendTodayPaymentNotification(payment, client); } else if (paymentDate < date.AddDays(3)) { this.Send3DayPaymentNotification(payment, client); } }
public bool SendMessage(EmailTemplateType type, Client client, string text = null) { var template = this.emailTemplatesService.GetByType(type); var body = template.Text; var subject = template.Subject; if (!string.IsNullOrEmpty(text)) { body = body.Replace("{text}", text); } subject = subject.Replace("{firstname}", client.FirstName); body = this.MassReplace( body, new Collection<KeyValuePair<string, string>> { new KeyValuePair<string, string>("{firstname}", client.FirstName), new KeyValuePair<string, string>("{lastname}", client.LastName), new KeyValuePair<string, string>("{time}", DateTime.Now.ToShortTimeString()), new KeyValuePair<string, string>("{date}", DateTime.Now.ToShortDateString()), new KeyValuePair<string, string>("{currentamount}", client.PrimaryAccount.Amount.ToString("C0")) }); subject = subject.Replace("{lastname}", client.FirstName); return this.SendMessage(subject, body, client.Email); }
public void CreateOrUpdate(Client client) { this.gangsterBankUnitOfWork.ClientsRepository.CreateOrUpdate(client); }
private static void CheckTakenLoansStatus(Client client) { foreach ( TakenLoan takenLoan in client.TakenLoans.Where(takenLoan => takenLoan.Status == TakenLoanStatus.Active)) { CheckTakenLoanStatus(takenLoan); } }
private decimal PayLoanPayments(Client client, decimal amount) { IEnumerable<LoanPayment> loanPayments = GetLoanPaymentsForPayment(client); foreach (LoanPayment loanPayment in loanPayments) { amount = TryPayLoanPayment(amount, loanPayment); CheckLoanPaymentStatus(loanPayment); if (amount == 0) { break; } } return amount; }
private void ProceedTakenLoans(TakenLoan takenLoans, DateTime date, Client client) { takenLoans.Payments.ForEach(x => this.ProceedPayment(x, date, client)); }
private static IEnumerable<LoanPayment> GetLoanPaymentsForPayment(Client client) { IEnumerable<LoanPayment> loanPayments = from takenLoan in client.TakenLoans where takenLoan.Status == TakenLoanStatus.Active from loanPayment in takenLoan.Payments where loanPayment.Status == LoanPaymentStatus.Active orderby loanPayment.Date select loanPayment; return loanPayments; }
private void CreateNewPayment(Client client, decimal amount, PaymentType type) { var payment = new Payment { Account = client.PrimaryAccount, Amount = amount, DateTime = DateTime.UtcNow, Type = type }; this.gangsterBankUnitOfWork.PaymentsRepository.CreateOrUpdate(payment); }
private UnconfirmedClientViewModel MapToUnconfirmedClientViewModel(Client client) { var model = new UnconfirmedClientViewModel { ClientId = client.Id, BirthDate = client.PersonalDetails.BirthDate, Employment = GetEmploymentText(client.PersonalDetails.EmploymentData), Name = GetNameText(client), Passport = GetPassportText(client.PersonalDetails.PassportData), PhoneNumber = client.PersonalDetails.Contacts.PhoneNumber, RegistrationAddress = GetAddressText( client.PersonalDetails.Contacts.RegistrationAddress) }; return model; }
private void SendMessagesToUser(Client client, DateTime date) { client.TakenLoans.Where(x => x.Status == TakenLoanStatus.Active) .ForEach(x => this.ProceedTakenLoans(x, date, client)); }
public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new Client() { UserName = model.UserName }; user.PersonalDetails = new PersonalDetails(); user.PersonalDetails.PassportData = new PassportData(); user.PersonalDetails.EmploymentData = new EmploymentData(); user.PersonalDetails.Contacts = new Contacts(); var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await userManager.AddToRoleAsync(user.Id, Role.Client.ToString()); await SignInAsync(user, isPersistent: false); return RedirectToAction("BasicDetails", "ClientProfile"); } AddErrors(result); } // If we got this far, something failed, redisplay form return View(model); }
private static void VerifyWorkFlow(Client client, LoanProduct loanProduct) { VerifyClientIsConfirmed(client); VerifyLoanProductIsNotActive(loanProduct); }
private static void VerifyClientIsConfirmed(Client client) { if (!client.IsConfirmed) { throw new WorkflowException("Client is not confirmed"); } }
public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return RedirectToAction("Manage"); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await AuthenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return View("ExternalLoginFailure"); } var user = new Client { UserName = model.UserName }; var result = await userManager.CreateAsync(user); if (result.Succeeded) { result = await userManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { await SignInAsync(user, isPersistent: false); return RedirectToLocal(returnUrl); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return View(model); }
public void Save(Client client) { Contract.Requires<ArgumentNullException>(client.IsNotNull()); this.gangsterBankUnitOfWork.ClientsRepository.CreateOrUpdate(client); }