public ActionResult DeleteConfirmed(int id)
        {
            TrainingExcersises trainingExcersises = db.TrainingExcersises.Find(id);

            db.TrainingExcersises.Remove(trainingExcersises);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Training,Excersise,TrainingSchemePartModel")] TrainingExcersises trainingExcersises)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trainingExcersises).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Excersise = new SelectList(db.Excersises, "Id", "ExcersiseName", trainingExcersises.Excersise);
     ViewBag.Training  = new SelectList(db.Trainings, "Id", "Id", trainingExcersises.Training);
     ViewBag.TrainingSchemePartModel = new SelectList(db.TrainingSchemePartModels, "Id", "PartLength", trainingExcersises.TrainingSchemePartModel);
     return(View(trainingExcersises));
 }
        // GET: TrainingExcersises/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TrainingExcersises trainingExcersises = db.TrainingExcersises.Find(id);

            if (trainingExcersises == null)
            {
                return(HttpNotFound());
            }
            return(View(trainingExcersises));
        }
        public PartialViewResult DeltTrainingExcersises(int Training, int TrainingSchemePart, int?excersise)
        {
            if (excersise != null)
            {
                TrainingExcersises te = db.TrainingExcersises.Find(excersise);
                db.TrainingExcersises.Remove(te);
                db.SaveChanges();
            }
            var trainingExcersises = db.TrainingExcersises.Include(t => t.Excersises).Include(t => t.Trainings).Include(t => t.TrainingSchemePartModels);

            trainingExcersises         = trainingExcersises.Where(t => t.Training == Training);
            trainingExcersises         = trainingExcersises.Where(t => t.TrainingSchemePartModel == TrainingSchemePart);
            ViewBag.TrainingSchemePart = TrainingSchemePart;
            ViewBag.Training           = Training;
            return(PartialView("_TrainingExcersisesList", trainingExcersises.ToList()));
        }
        // GET: TrainingExcersises/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TrainingExcersises trainingExcersises = db.TrainingExcersises.Find(id);

            if (trainingExcersises == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Excersise = new SelectList(db.Excersises, "Id", "ExcersiseName", trainingExcersises.Excersise);
            ViewBag.Training  = new SelectList(db.Trainings, "Id", "Id", trainingExcersises.Training);
            ViewBag.TrainingSchemePartModel = new SelectList(db.TrainingSchemePartModels, "Id", "PartLength", trainingExcersises.TrainingSchemePartModel);
            return(View(trainingExcersises));
        }
        public PartialViewResult GetTrainingExcersises(int Training, int TrainingSchemePart, int?ExcersiseList)
        {
            if (ExcersiseList != null)
            {
                TrainingExcersises trainingExcersisesAdd = new TrainingExcersises();
                trainingExcersisesAdd.Training  = Training;
                trainingExcersisesAdd.Excersise = ExcersiseList.Value;
                trainingExcersisesAdd.TrainingSchemePartModel = TrainingSchemePart;
                db.TrainingExcersises.Add(trainingExcersisesAdd);
                db.SaveChanges();
            }
            var trainingExcersises = db.TrainingExcersises.Include(t => t.Excersises).Include(t => t.Trainings).Include(t => t.TrainingSchemePartModels);

            trainingExcersises         = trainingExcersises.Where(t => t.Training == Training);
            trainingExcersises         = trainingExcersises.Where(t => t.TrainingSchemePartModel == TrainingSchemePart);
            ViewBag.TrainingSchemePart = TrainingSchemePart;
            ViewBag.Training           = Training;
            return(PartialView("_TrainingExcersisesList", trainingExcersises.ToList()));
        }