Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            EconomyAccount economyAccount = db.EconomyAccounts.Find(id);

            db.EconomyAccounts.Remove(economyAccount);
            db.SaveChanges();
            //return RedirectToAction("Index");
            return(RedirectToAction("ActiveLoansAndEconomyAccountsIndex", "ActiveLoansAndEconomyAccounts"));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "EconomyAccountId,DepositAmount,DateStarted,Duration,InterestRate,ProfitFromInterest,TaxedAmount")] EconomyAccount economyAccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(economyAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EconomyAccountId = new SelectList(db.Members, "Id", "NameAndPID", economyAccount.EconomyAccountId);
     return(View(economyAccount));
 }
Ejemplo n.º 3
0
        // GET: EconomyAccount/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EconomyAccount economyAccount = db.EconomyAccounts.Find(id);

            if (economyAccount == null)
            {
                return(HttpNotFound());
            }
            return(View(economyAccount));
        }
Ejemplo n.º 4
0
        // GET: EconomyAccount/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EconomyAccount economyAccount = db.EconomyAccounts.Find(id);

            if (economyAccount == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EconomyAccountId = new SelectList(db.Members, "Id", "NameAndPID", economyAccount.EconomyAccountId);
            return(View(economyAccount));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "EconomyAccountId,DepositAmount,DateStarted,Duration")] EconomyAccount economyAccount)
        {
            if (ModelState.IsValid)
            {
                // Check if a member already has an account
                if (db.EconomyAccounts.Find(economyAccount.EconomyAccountId) != null)
                {
                    return(RedirectToAction("AlreadyHasEconomyAccount"));
                }

                // Member doesn't already have an account so just proceed forward, he is eligible for an account


                // Get the latest InterestRate
                var latestInterestRate = db.EconomyAccountInterests.OrderByDescending(p => p.Date)
                                         .FirstOrDefault();

                economyAccount.InterestRate = latestInterestRate.Percentage;


                // Convert the duration (months to integer then to decimal
                decimal monthsToDecimal = Convert.ToDecimal(ConvertEnumMonthsToInteger(economyAccount.Duration));

                // Profit from interest
                economyAccount.ProfitFromInterest = (((economyAccount.DepositAmount * 30) / 360) *
                                                     economyAccount.InterestRate * monthsToDecimal) - economyAccount.DepositAmount;

                // Taxed Amount
                economyAccount.TaxedAmount = (economyAccount.ProfitFromInterest * 10) / 100;


                db.EconomyAccounts.Add(economyAccount);

                db.SaveChanges();


                //return RedirectToAction("ActiveLoansAndEconomyAccountsIndex", "ActiveLoansAndEconomyAccounts");

                var newlyCreatedEconomyAccount = db.EconomyAccounts.SingleOrDefault(b => b.EconomyAccountId == economyAccount.EconomyAccountId);

                return(RedirectToAction("EconomyAccountSummary", new { idOfEconomyAccount = newlyCreatedEconomyAccount.EconomyAccountId }));
            }

            // change select list to one with ID and name like on Loan
            ViewBag.EconomyAccountId = new SelectList(db.Members, "Id", "NameAndPID", economyAccount.EconomyAccountId);
            return(View(economyAccount));
        }