public void SavePlan(Plan plan)
 {
     if (plan.PlanId == 0)
     {
         context.Plans.Add(plan);
     }
     context.SaveChanges();
 }
        public ActionResult Edit(Plan plan)
        {
            if (ModelState.IsValid)
            {
                // save the plan
                repository.SavePlan(plan);
                // add a message to the viewbag
                TempData["message"] = string.Format("{0} has been saved", plan.PlanName);

                return RedirectToAction("Index");
            }
            else
            {
                // there is something wrong with the data values
                return View(plan);
            }
        }
 public void DeletePlan(Plan plan)
 {
     context.Plans.Remove(plan);
     context.SaveChanges();
 }