Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        // 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));
        }
Exemplo n.º 3
0
        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" }));
        }
Exemplo n.º 4
0
        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));
        }