public ActionResult Edit(int id)
        {
            SpendingModel spending;

            using (var context = new DollaDollaContext())
            {
                spending = context.Spendings.Single(x => x.Id == id);
            }
            return(View(spending));
        }
        // GET: Spending
        public ActionResult Index()
        {
            SpendingModel spending;

            using (var context = new DollaDollaContext())
            {
                spending = context.Spendings.FirstOrDefault();
            }
            return(View(spending));
        }
        public ActionResult Index()
        {
            TotalBillsModel totalModel = null;

            using (var context = new DollaDollaContext())
            {
                totalModel = context.TotalBills.Include(c => c.Receipts).FirstOrDefault(x => x.Id == 1);
            }
            return(View(totalModel));
        }
 public ActionResult CreateSpendingModel(SpendingModel model)
 {
     if (!ModelState.IsValid)
     {
         throw new HttpException(400, "Invalid Submission");
     }
     using (var context = new DollaDollaContext())
     {
         context.Spendings.Add(model);
         context.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult DeleteReceipt(int ReceiptId)
 {
     using (var context = new DollaDollaContext())
     {
         var receipt = context.Receipts.FirstOrDefault(r => r.Id == ReceiptId);
         if (receipt == null)
         {
             throw new NullReferenceException("");
         }
         context.Receipts.Remove(receipt);
         context.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
 public ActionResult AddReceipt(Receipt receipt)
 {
     if (!ModelState.IsValid)
     {
         throw new HttpException(400, "Invalid Moel State");
     }
     using (var context = new DollaDollaContext())
     {
         var totalbills = context.TotalBills.First(x => x.Id == 1);
         totalbills.Total += receipt.Amount;
         totalbills.Receipts.Add(receipt);
         context.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }