Esempio n. 1
0
        public ActionResult updateWeights(weightsModel _updateWeights)
        {
            if ((int)Session["FK_roleID"] == 1 || (int)Session["FK_roleID"] == 2 || (int)Session["FK_roleID"] == 3)
            {
                // if model state is valid
                if (ModelState.IsValid)
                {
                    try
                    {
                        // getting the FK_routineWorkoutID from session variable FK_routineWorkoutID
                        _updateWeights.FK_routineWorkID = (int)Session["FK_routineWorkID"];

                        // updating the the routine exercises based to the id
                        _routineWorkoutDataAccess.updateWeights(_mapper.map(_updateWeights));

                        // making new instance of routine model
                        routineModel modelforid = new routineModel();
                        // setting routineID to updated FK routineWorkoutID
                        modelforid.routineID = _updateWeights.FK_routineWorkID;

                        // returning back the page view routine workout
                        return(RedirectToAction("viewRoutineWorkout", modelforid));
                    }
                    catch (Exception _error)
                    {
                        // putting error into a file
                        _logger.logError(_error);
                    }
                }
            }
            return(View());
        }
Esempio n. 2
0
        public ActionResult addRoutine(routineModel _addRoutine)
        {
            if ((int)Session["FK_roleID"] == 1 || (int)Session["FK_roleID"] == 2 || (int)Session["FK_roleID"] == 3 && _addRoutine.FK_personID == (int)Session["personID"])
            {
                try
                {
                    // if model state is valid
                    if (ModelState.IsValid)
                    {
                        try
                        {
                            // adding routine back to the database
                            _routineDataAccess.addingRoutine(_mapper.map(_addRoutine));

                            // redirecting back to view Routine
                            return(RedirectToAction("viewRoutine"));
                        }
                        catch (Exception _error)
                        {
                            // putting error into a file
                            _logger.logError(_error);
                        }
                    }
                    return(View());
                }
                catch (Exception _error)
                {
                    // putting error into a file
                    _logger.logError(_error);
                }
            }
            // returning error page
            return(View("Error"));
        }
Esempio n. 3
0
 public ActionResult updateRoutine(routineModel _updateRoutine)
 {
     if ((int)Session["FK_roleID"] == 1 || (int)Session["FK_roleID"] == 2 || (int)Session["FK_roleID"] == 3)
     {
         try
         {
             // if model state is valid
             if (ModelState.IsValid)
             {
                 try
                 {
                     // updating the routine in database
                     _routineDataAccess.updateRoutine(_mapper.map(_updateRoutine));
                     // redirecting back to view routine
                     return(RedirectToAction("viewRoutine"));
                 }
                 catch (Exception _error)
                 {
                     // putting error into a file
                     _logger.logError(_error);
                 }
             }
             return(View());
         }
         catch (Exception _error)
         {
             // putting error into a file
             _logger.logError(_error);
         }
     }
     // return error page
     return(View("Error"));
 }
        public ActionResult deleteRoutineWorkout(int _deleteRoutineWorkout)
        {
            if ((int)Session["FK_roleID"] == 1 || (int)Session["FK_roleID"] == 2 || (int)Session["FK_roleID"] == 3)
            {
                try
                {
                    // deleting the routineWorkout based to the ID from the database
                    _routineWorkoutDataAccess.deletingRoutineWorkout(_deleteRoutineWorkout);

                    // making new instance of the routine
                    routineModel modelforid = new routineModel();

                    // setting routineID to the session fk_routineworkout ID
                    modelforid.routineID = (int)Session["FK_routineWorkoutID"];

                    // redirect back to new routineworkout using model for id model
                    return(RedirectToAction("viewRoutineWorkout", modelforid));
                }
                catch (Exception _error)
                {
                    // putting error into a file
                    _logger.logError(_error);
                }
            }

            // return error page
            return(View("Error"));
        }
        public ActionResult viewRoutineWorkout(routineModel _viewRoutine)
        {
            if ((int)Session["FK_roleID"] == 1 || (int)Session["FK_roleID"] == 2 || (int)Session["FK_roleID"] == 3)
            {
                try
                {
                    // setting personID to the session varibale personID
                    int _personID = (int)Session["personID"];

                    // showing routineID in url
                    // setting routineID to the view routine routineID
                    int _routineID = _viewRoutine.routineID;

                    // making new instance of the view model
                    viewModel viewRoutineW = new viewModel();
                    // populating routine workout list from the batabase that matches personID and routineID
                    viewRoutineW.routineWorkoutList = _mapper.map(_routineWorkoutDataAccess.listAllRoutineWorkout(_personID, _routineID));

                    // setting session variable FK_routineWorkoutID to view routine. routineID
                    Session["FK_routineWorkoutID"] = _viewRoutine.routineID;

                    // return back view with view routine Workout
                    return(View(viewRoutineW));
                }
                catch (Exception _error)
                {
                    // putting error into a file
                    _logger.logError(_error);
                }
            }
            // return error page
            return(View("Error"));
        }
Esempio n. 6
0
 public ActionResult addRoutineGet(routineModel _addRoutine)
 {
     if ((int)Session["FK_roleID"] == 1 || (int)Session["FK_roleID"] == 2 || (int)Session["FK_roleID"] == 3)
     {
         // adding personID variable from session to the routine
         _addRoutine.FK_personID = (int)Session["personID"];
         // getting the add routine view
         return(View(_addRoutine));
     }
     return(View("Error"));
 }
        public ActionResult addRoutineWorkout(routineWorkoutModel _addRoutineWorkout)
        {
            if ((int)Session["FK_roleID"] == 1 || (int)Session["FK_roleID"] == 2 || (int)Session["FK_roleID"] == 3)
            {
                try
                {
                    // if model state is valid
                    if (ModelState.IsValid)
                    {
                        try
                        {
                            // using session varible to get the FK routineWorkoutID
                            _addRoutineWorkout.FK_routineWorkoutID = (int)Session["FK_routineWorkoutID"];
                            // then adding the the routin workout to the database with the ID
                            _routineWorkoutDataAccess.addingRoutineWorkout(_mapper.map(_addRoutineWorkout));

                            // making new instance of routine model
                            routineModel modelforID = new routineModel();
                            // setting routineID for modelforID to addingRoutineWorkout FK routineWorkout ID
                            modelforID.routineID = _addRoutineWorkout.FK_routineWorkoutID;

                            // return back to routineWorkout page that belongs to the modelforID
                            return(RedirectToAction("viewRoutineWorkout", modelforID));
                        }
                        catch (Exception _error)
                        {
                            // putting error into a file
                            _logger.logError(_error);
                        }
                    }
                    return(View());
                }
                catch (Exception _error)
                {
                    // putting error into a file
                    _logger.logError(_error);
                }
            }
            return(View("Error"));
        }
Esempio n. 8
0
        public ActionResult updateRoutineGet(routineModel routine)
        {
            if ((int)Session["FK_roleID"] == 1 || (int)Session["FK_roleID"] == 2 || (int)Session["FK_roleID"] == 3)
            {
                try
                {
                    //  making session id routine and person id with routine model
                    Session["routineID"]   = routine.routineID;
                    Session["FK_personID"] = routine.FK_personID;

                    // returning view of routine
                    return(View(routine));
                }
                catch (Exception _error)
                {
                    // putting error into a file
                    _logger.logError(_error);
                }
            }
            // return to error page
            return(View("Error"));
        }