public ActionResult CreatePlan(PlanTpeViewModel tp)
 {
     if (ModelState.IsValid)
     {
         using (var dbContext = new Model1())
         {
             tp.Plan.PlanId = TrainingPlan.GenerateId();
             tp.Plan.Coach  = Int32.Parse(Session["UserID"].ToString());
             dbContext.TrainingPlan.Add(tp.Plan);
             dbContext.SaveChanges();
         }
     }
     ModelState.Clear();
     return(RedirectToAction("EditPlan", "Trainer", new { planId = tp.Plan.PlanId }));
 }
        public ActionResult CreatePlan()
        {
            PlanTpeViewModel plan = new PlanTpeViewModel();

            plan.DropDownItems = new List <SelectListItem>();
            using (var dbContext = new Model1())
            {
                foreach (var tt in dbContext.TrainingType.ToList())
                {
                    plan.DropDownItems.Add(new SelectListItem {
                        Text = tt.Name, Value = tt.TypeId + ""
                    });
                }
            }
            return(View(plan));
        }