private bool CheckValidateLoanState(LoanRepaymentScheduleCalculator calc) { try { calc.GetState(); // ReSharper disable once CatchAllClause } catch (Exception e) { this.Result.Error = e.Message; Log.Alert("LoanRepaymentScheduleCalculator STATE EXCEPTION: {0}", e); return(false); } // additional validating - via "edit loan" GUI model ChangeLoanDetailsModelBuilder changeLoanModelBuilder = new ChangeLoanDetailsModelBuilder(); EditLoanDetailsModel model = changeLoanModelBuilder.BuildModel(this.tLoan); model.Validate(); if (model.HasErrors) { this.Result.Error = string.Join("<br/>", model.Errors.ToArray()); Log.Alert(this.Result.Error); return(false); } return(true); }
public void SetUp() { _loanOriginal = new Loan(); _cashRequest = new CashRequest() { InterestRate = 0.06m, LoanType = new StandardLoanType() }; _calculator = new LoanScheduleCalculator(); _calculator.Calculate(1000, _loanOriginal, new DateTime(2012, 10, 21)); _builder = new ChangeLoanDetailsModelBuilder(); }
public void Init() { var pacnetService = new Mock <IPacnetService>(); pacnetService.Setup(x => x.SendMoney(It.IsAny <int>(), It.IsAny <decimal>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(new PacnetReturnData()); var agreementsGenerator = new Mock <IAgreementsGenerator>(); var context = new Mock <IEzbobWorkplaceContext>(); _loanDetailsModelBuilder = new ChangeLoanDetailsModelBuilder(); _loanBuilder = new LoanBuilder(_loanDetailsModelBuilder); _lc = new LoanCreator(pacnetService.Object, agreementsGenerator.Object, context.Object, _loanBuilder, null); SetUp(); }
public CustomerModelBuilder( ISecurityQuestionRepository questions, ICustomerRepository customerRepository, IUsersRepository users, PaymentRolloverRepository paymentRolloverRepository, DatabaseDataHelper oDbHelper, WhiteLabelProviderRepository whiteLabelProviderRepository ) { m_oQuestions = questions; m_oCustomerRepository = customerRepository; m_oUsers = users; m_oPaymentRolloverRepository = paymentRolloverRepository; m_oChangeLoanDetailsModelBuilder = new ChangeLoanDetailsModelBuilder(); m_oExperianDirectors = oDbHelper.ExperianDirectorRepository; _whiteLabelProviderRepository = whiteLabelProviderRepository; } // constructor
public LoanEditorController( ILoanRepository loans, ILoanOptionsRepository loanOptions, ChangeLoanDetailsModelBuilder builder, ICashRequestRepository cashRequests, ChangeLoanDetailsModelBuilder loanModelBuilder, LoanBuilder loanBuilder, ILoanChangesHistoryRepository history, IWorkplaceContext context, ILoanOptionsRepository loanOptionsRepository, ISession session) { this._loans = loans; this._cashRequests = cashRequests; this._loanModelBuilder = loanModelBuilder; this._loanBuilder = loanBuilder; this._history = history; this._context = context; this.loanOptionsRepository = loanOptionsRepository; this.serviceClient = new ServiceClient(); }
public LoanBuilder(ChangeLoanDetailsModelBuilder builder) { _builder = builder; } // constructor
/// <summary> /// sending mail on re-schedule saving /// </summary> /// <param name="subject"></param> /// <param name="toAddress"></param> /// <param name="transactionEx"></param> private void SendMail(string subject, string toAddress = null, Exception transactionEx = null) { if (toAddress == null) { toAddress = this.emailToAddress; } subject = subject + " for customerID: " + this.tLoan.Customer.Id + ", by userID: " + Context.UserID + ", Loan ref: " + this.tLoan.RefNumber; var stateBefore = JsonConvert.DeserializeObject <EditLoanDetailsModel>(this.loanHistory.Data).Items; StringBuilder sb = new StringBuilder(); if (stateBefore != null) { foreach (var i in stateBefore) { sb.Append("<p>").Append(i).Append("</p>"); } } this.tLoan = this.loanRep.Get(this.ReschedulingArguments.LoanID); var calc = new LoanRepaymentScheduleCalculator(this.tLoan, DateTime.UtcNow, CurrentValues.Instance.AmountToChargeFrom); calc.GetState(); var currentState = new ChangeLoanDetailsModelBuilder().BuildModel(this.tLoan).Items; StringBuilder currentStateStr = new StringBuilder(); if (currentState != null) { foreach (var ii in currentState) { currentStateStr.Append("<p>").Append(ii).Append("</p>"); } } string beforeStateString = this.sbBeforeLoanState.ToString(); string currentStateString = this.tLoan.ToString(); this.message = string.Format( "<h3>CustomerID: {0}; UserID: {1}</h3>" + "<h5>Arguments</h5> <pre>{2}</pre>" + "<h5>Result</h5> <pre>{3}</pre>" + "<h5>Error</h5> {4}" + "<h5>Loan state before action</h5> <pre>{5}</pre>" + "<h5>Current schedule - after action</h5> <pre>{6}</pre>" + "<br/><br/><br/>===================================<h5>Loan state before in view model</h5> {7}" + "<h5>Current schedule after action in view model</h5> {8}", this.tLoan.Customer.Id, Context.UserID , (this.ReschedulingArguments) , (this.Result) , (transactionEx == null ? "NO errors" : transactionEx.ToString()) , (beforeStateString.Length > 0) ? beforeStateString : "not found" , (currentStateString.Length > 0) ? currentStateString : "not found" , (sb.ToString().Length > 0) ? sb.ToString() : "not found" , (currentStateStr.ToString().Length > 0) ? currentStateStr.ToString() : "not found" ); new Mail().Send( toAddress, null, // message text this.message, // html this.emailFromAddress, // fromEmail this.emailFromName, // fromName subject // subject ); } // SendMail