//
        // GET: /Reimbursement/Edit/5
        public ActionResult Approve(int id, Reimbursement collection, Budget budget)
        {
            var ApplicantId = db.Applicants.Single(a => a.Reimbursements.Where(b => b.Id == id).Any()).Id;
            collection = db.Reimbursements.Single(a => a.Id == id);
            var BudgetId = db.Reimbursements.Single(a => a.Id == id).BudgetId;
            budget = db.Budgets.Single(a => a.Id == BudgetId);

            var ReimbursementAmount = collection.Amount;
            var BudgetAmount = budget.Amount;
            var NewBudgetAmount = BudgetAmount - ReimbursementAmount;
            collection.ActiveNow = false;
            collection.DateApproved = DateTime.Now;
            budget.Amount = NewBudgetAmount;

            if (ModelState.IsValid)
            {

                UpdateModel(collection);
                db.SaveChanges();

                return RedirectToAction("Index", new { id = ApplicantId });
            }
            else
            {
                return View(collection);
            }
        }
        //
        // GET: /Reimbursement/Create
        public ActionResult Create(int id)
        {
            ViewBag.ApplicantId = db.Applicants.Single(a => a.Id == id).Id;
            Reimbursement reimbursement = new Reimbursement();
            reimbursement.ApplicantId = id;

            ViewBag.TypeId = new SelectList(db.Types, "Id", "Name");
            ViewBag.BudgetId = new SelectList(db.Budgets, "Id", "Number");

            return View(reimbursement);
        }
        public ActionResult Create(int id, Reimbursement collection)
        {
            ViewBag.TypeId = new SelectList(db.Types, "Id", "Name");
            ViewBag.BudgetId = new SelectList(db.Budgets, "Id", "Number");

            if (ModelState.IsValid)
            {
                collection.ActiveNow = true;
                collection.ApprovedBy = "Alex Riabov";
                collection.DateAdded = DateTime.Now;

                db.Reimbursements.AddObject(collection);
                db.SaveChanges();
                return RedirectToAction("Index", new { id = id });
            }
            else
            {
                return View(collection);
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Reimbursements EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToReimbursements(Reimbursement reimbursement)
 {
     base.AddObject("Reimbursements", reimbursement);
 }
 /// <summary>
 /// Create a new Reimbursement object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="applicantId">Initial value of the ApplicantId property.</param>
 /// <param name="typeId">Initial value of the TypeId property.</param>
 /// <param name="budgetId">Initial value of the BudgetId property.</param>
 /// <param name="amount">Initial value of the Amount property.</param>
 public static Reimbursement CreateReimbursement(global::System.Int32 id, global::System.Int32 applicantId, global::System.Int32 typeId, global::System.Int32 budgetId, global::System.Int32 amount)
 {
     Reimbursement reimbursement = new Reimbursement();
     reimbursement.Id = id;
     reimbursement.ApplicantId = applicantId;
     reimbursement.TypeId = typeId;
     reimbursement.BudgetId = budgetId;
     reimbursement.Amount = amount;
     return reimbursement;
 }
 public ActionResult Delete(int id, Reimbursement collection)
 {
     var ApplicantId = db.Applicants.Single(a => a.Reimbursements.Where(b => b.Id == id).Any()).Id;
     collection = db.Reimbursements.Single(a => a.Id == id);
     if (ModelState.IsValid)
     {
         db.DeleteObject(collection);
         db.SaveChanges();
         return RedirectToAction("Index", new { id = ApplicantId });
     }
     else
     {
         return View();
     }
 }
        public ActionResult Edit(int id, Reimbursement collection)
        {
            collection = db.Reimbursements.Single(a => a.Id == id);

            ViewBag.TypeId = new SelectList(db.Types, "Id", "Name");
            ViewBag.BudgetId = new SelectList(db.Budgets, "Id", "Number");

            if (ModelState.IsValid)
            {
                // TODO: Add insert logic here
                UpdateModel(collection);
                db.SaveChanges();

                return RedirectToAction("Details", new { id = id});
            }
            else
            {
                return View(collection);
            }
        }