public LoanController(ILoanView view, IList loanList)// { _view = view; _LoansList = loanList; view.SetController(this); loanService = new LoanService(); }
public void Execute() { IDialog dialog = factory.CreateDialog(); IClientView clientView = factory.CreateClientView(); ILoanView loanView = factory.CreateLoanView(); Client client = GetClient(dialog); Loan loan = GetLoan(dialog); client.Notify(loan.GetValues()); loan.AddObserver(client); }
/// <summary> /// Saves the loan information. /// </summary> /// <param name="loanInfo">The loan information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException">loanInfo</exception> public string SaveLoanInfo(ILoanView loanInfo) { if (loanInfo == null) { throw new ArgumentNullException(nameof(loanInfo)); } var result = string.Empty; var newRecord = new LoanType { LoanType1 = loanInfo.LoanType, //LoanAmount = loanInfo.LoanAmount, //InterestRate = loanInfo.InterestRate, //DeductionRate = loanInfo.DeductionRate, //Duration = loanInfo.Duration, IsActive = true, DateCreated = DateTime.UtcNow, // CompanyId = loanInfo.CompanyId }; try { using ( var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { dbContext.LoanTypes.Add(newRecord); dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("Save Loan Information - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }
/// <summary> /// Updates the loan information. /// </summary> /// <param name="loanInfo">The loan information.</param> /// <returns></returns> /// <exception cref="ArgumentNullException"> /// loanInfo /// or /// loanData /// </exception> public string UpdateLoanInfo(ILoanView loanInfo) { if (loanInfo == null) { throw new ArgumentNullException(nameof(loanInfo)); } var result = string.Empty; try { using ( var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS)) { var loanData = dbContext.LoanTypes.SingleOrDefault(m => m.LoanTypeId.Equals(loanInfo.LoanType)); if (loanData == null) { throw new ArgumentNullException(nameof(loanData)); } loanData.LoanType1 = loanInfo.LoanType; dbContext.SaveChanges(); } } catch (Exception e) { result = string.Format("Update Loan Information - {0} , {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } return(result); }