예제 #1
0
        public ActionResult Details(int idTraining)
        {
            ViewBag.Units = TrainingBL.GetUnits();

            var training = new Training();

            var db = new DatabaseConnection(Server.MapPath("~"));

            db.connection.Open();

            ViewBag.Movements = TrainingBL.GetMovementTypes(db);
            training.Header   = TrainingBL.GetHeader(idTraining, db);

            if (training.Header.IdUser == (int)Session["IdUser"])
            {
                training.Exercises = TrainingBL.GetExercices(idTraining, db);
            }
            //Prevents users from accessing other users trainings
            else
            {
                return(RedirectToAction("Index", "Training"));
            }

            db.connection.Close();

            if (!training.Exercises.Any())
            {
                training.Exercises.Add(new Exercise());
            }

            return(View(training));
        }
예제 #2
0
        public ActionResult Create()
        {
            var training = new Training();

            training.Header.Date = DateTime.Today;
            training.Exercises.Add(new Exercise());

            ViewBag.Units = TrainingBL.GetUnits();

            var db = new DatabaseConnection(Server.MapPath("~"));

            db.connection.Open();

            ViewBag.Movements = TrainingBL.GetMovementTypes(db);

            db.connection.Close();

            return(View(training));
        }