Example #1
0
        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);
        }
Example #2
0
        private EditLoanDetailsModel RecalculateModel(EditLoanDetailsModel model, CashRequest cr, DateTime now)
        {
            model.Validate();

            if (model.HasErrors)
            {
                return(model);
            }

            var loan = this._loanModelBuilder.CreateLoan(model);

            loan.LoanType    = cr.LoanType;
            loan.CashRequest = cr;

            RescheduleSetmodel(model.Id, model);

            try {
                var calc = new LoanRepaymentScheduleCalculator(loan, now, CurrentValues.Instance.AmountToChargeFrom);
                calc.GetState();

                //try {
                //	long nlLoanId = this.serviceClient.Instance.GetLoanByOldID(loan.Id, cr.Customer.Id, this._context.UserId).Value;
                //	if (nlLoanId > 0) {
                //		var nlModel = this.serviceClient.Instance.GetLoanState(loan.Customer.Id, nlLoanId, now, this._context.UserId, true).Value;
                //		Log.InfoFormat("<<< NL_Compare: nlModel : {0} loan: {1}  >>>", nlModel, loan);
                //	}
                //	// ReSharper disable once CatchAllClause
                //} catch (Exception ex) {
                //	Log.InfoFormat("<<< NL_Compare Fail at: {0}, err: {1}", Environment.StackTrace, ex.Message);
                //}
            } catch (Exception e) {
                model.Errors.Add(e.Message);
                return(model);
            }

            return(this._loanModelBuilder.BuildModel(loan));
        }