//
        // 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);
            }
        }
 public ActionResult Create(Budget collection)
 {
     if (ModelState.IsValid)
     {
         collection.Date = DateTime.Now;
         db.Budgets.AddObject(collection);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     else
     {
         return View(collection);
     }
 }
 /// <summary>
 /// Create a new Budget object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="number">Initial value of the Number property.</param>
 /// <param name="amount">Initial value of the Amount property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 public static Budget CreateBudget(global::System.Int32 id, global::System.String number, global::System.Int32 amount, global::System.DateTime date)
 {
     Budget budget = new Budget();
     budget.Id = id;
     budget.Number = number;
     budget.Amount = amount;
     budget.Date = date;
     return budget;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Budgets EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBudgets(Budget budget)
 {
     base.AddObject("Budgets", budget);
 }
        public ActionResult Edit(int id, Budget collection)
        {
            collection = db.Budgets.Single(a => a.Id == id);

            try
            {
                UpdateModel(collection);
                db.SaveChanges();

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

            }
            catch
            {
                return View();
            }
        }
 //
 // GET: /Budget/Create
 public ActionResult Create()
 {
     Budget budget = new Budget();
     return View(budget);
 }