public ActionResult Details(int?id, int?newBaseRateId) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Agreement agreement = db.Agreements.Find(id); if (agreement == null) { return(HttpNotFound()); } if (newBaseRateId == null) { return(View(agreement)); } BaseRate baseRate = db.BaseRates.Find(newBaseRateId); agreement.InterestRate = InterBankRates.GetInterestRate(agreement.BaseRate.BaseRateCode, agreement.Margin); agreement.NewInterestRate = InterBankRates.GetInterestRate(baseRate.BaseRateCode, agreement.Margin); agreement.InterestRatesDiff = agreement.InterestRate - agreement.NewInterestRate; agreement.NewBaseRateId = (int)newBaseRateId; ViewBag.NewBaseRateId = GetBaseRatesDropdown(); return(View(agreement)); }
// GET: Agreements/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Agreement agreement = db.Agreements.Find(id); if (agreement == null) { return(HttpNotFound()); } agreement.InterestRate = InterBankRates.GetInterestRate(agreement.BaseRate.BaseRateCode, agreement.Margin); ViewBag.CustomerId = GetCustomersDropDown(agreement.CustomerId); ViewBag.BaseRateId = GetBaseRatesDropdown(agreement.BaseRateId); return(View(agreement)); }
public ActionResult GetNewInterestRate(int?id, int?val) { if (id != null && val != null) { Agreement agreement = db.Agreements.Find(id); BaseRate baseRate = db.BaseRates.Find(val); var InterestRate = InterBankRates.GetInterestRate(agreement.BaseRate.BaseRateCode, agreement.Margin); var NewInterestRate = InterBankRates.GetInterestRate(baseRate.BaseRateCode, agreement.Margin); return(Json(new { Success = "true", Data = new { CurrentInterestRate = InterestRate, NewInterestRate = NewInterestRate, InterestRatesDiff = InterestRate - NewInterestRate } })); } return(Json(new { Success = "false" })); }
public IHttpActionResult Get( long CustomerPersonalId, string BaseRateCode, string NewBaseRateCode, int Amount, decimal Margin, int Duration ) { var Customer = db.Customers.FirstOrDefault(m => m.PersonalId == CustomerPersonalId); if (Customer == null) { return(NotFound()); } var BaseRate = db.BaseRates.FirstOrDefault(m => m.BaseRateCode == BaseRateCode); if (BaseRate == null) { return(NotFound()); } var NewBaseRate = db.BaseRates.FirstOrDefault(m => m.BaseRateCode == NewBaseRateCode); var InterestRate = InterBankRates.GetInterestRate(BaseRate.BaseRateCode, Margin); var NewInterestRate = InterBankRates.GetInterestRate(NewBaseRate.BaseRateCode, Margin); AgreementApiViewModel Agreement = new Agreement { Amount = Amount, BaseRate = BaseRate, Customer = Customer, Duration = Duration, InterestRate = InterestRate, Margin = Margin, NewInterestRate = NewInterestRate, InterestRatesDiff = InterestRate - NewInterestRate }; return(Ok(Agreement)); }