public ActionResult EditPlan([Bind(Include = "ID,pattern_id,training_id,start_date,end_date,orders")] training_patterns plan)
        {
            //It must be check for various conditions:
            //1.start date must be bigger than the class start date
            //2.end date must be smaller than the class end date
            //3. start date must be smaller than end date
            var trn = db.training_terms.Find(plan.training_id);

            if (plan.e_date < trn.s_date ||
                plan.e_date > trn.e_date ||
                plan.s_date > plan.e_date ||
                plan.s_date < trn.s_date ||
                plan.s_date > trn.e_date)
            {
                Session["TACTION_RESULT"] = lang.dateError;
                return(this.RedirectToAction("Plans", plan.ID));
            }

            if (ModelState.IsValid)
            {
                db.Entry(plan).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Plans", new { id = plan.training_id }));
            }
            Session["TACTION_RESULT"] = lang.generalError;
            return(this.RedirectToAction("Plans", plan.ID));
        }
        public ActionResult CreatePlan([Bind(Include = "ID,pattern_id,training_id,start_date,end_date,orders")] training_patterns plan)
        {
            var trn = db.training_terms.Find(plan.training_id);

            if (plan.e_date < trn.s_date ||
                plan.e_date > trn.e_date ||
                plan.s_date > plan.e_date ||
                plan.s_date < trn.s_date ||
                plan.s_date > trn.e_date)
            {
                Session["TACTION_RESULT"] = lang.dateError;
                return(View(plan));
            }

            if (ModelState.IsValid)
            {
                db.training_patterns.Add(plan);
                db.SaveChanges();
                return(RedirectToAction("Plans", new { id = plan.training_id }));
            }

            return(RedirectToAction("Createplan", plan.training_id));
        }