public void LoadDefaultModels()
        {
            if (_defaultModelLoaded == false)
            {
                Exercise benchPress    = new Exercise(1, "Bench press", MuscleGroup.CHEST, "Lie down on a flat bench under a barbell. Lower the barbell towards your chest, once it hits the chest, push it back up.", "bench_press");
                Exercise militaryPress = new Exercise(2, "Military press", MuscleGroup.SHOULDERS, "Stand up with a barbell resting on your upper chest. Press the weight straight up above your head, and then lower it back down.", "military_press");
                Exercise squat         = new Exercise(3, "Squat", MuscleGroup.LEGS, "Stand up with a barbell resting on your upper back. Squat down until your thighs are parallel to the floor and then stand back up.", "squat");
                Exercise deadlift      = new Exercise(4, "Deadlift", MuscleGroup.LEGS, "Stand up with a barbell resting on the floor in front of you. Squat down and grab onto the bar outside your thighs. Arch your back and then simply stand up.", "deadlift");
                Exercise dumbbellCurl  = new Exercise(5, "Dumbbell curl", MuscleGroup.BICEPS, "Stand up with one dumbbell in each hand. Curl the dumbbells up to shoulder level and then lower them back down.", "dumbbell_curl");
                Exercise ropePushDown  = new Exercise(6, "Rope pushdown", MuscleGroup.TRICEPS, "Stand up in a cable machine. Grab the rope with both hands with your elbows tucked in at your sides. Push the rope down then bring it back up.", "rope_pushdown");
                Exercise pullUp        = new Exercise(7, "Pullup", MuscleGroup.BACK, "Hang freely from a pullup bar with a little wider than shoulder width grip. Pull yourself up until your chin is above the bar, then lower yourself back down.", "pullup");
                Exercise situp         = new Exercise(8, "Situp", MuscleGroup.ABS, "Lie down flat on your back and lift your torso with your hands behind your head. Once your torso is completely straight, lower yourself down to start position.", "situp");

                _exerciseRepository.AddExercise(benchPress);
                _exerciseRepository.AddExercise(militaryPress);
                _exerciseRepository.AddExercise(squat);
                _exerciseRepository.AddExercise(deadlift);
                _exerciseRepository.AddExercise(dumbbellCurl);
                _exerciseRepository.AddExercise(ropePushDown);
                _exerciseRepository.AddExercise(pullUp);
                _exerciseRepository.AddExercise(situp);

                _workoutRepository.AddWorkout(new Workout(1, "Upper body", new List <Exercise>()
                {
                    benchPress, militaryPress
                }, 4));
                _workoutRepository.AddWorkout(new Workout(2, "Lower body", new List <Exercise>()
                {
                    squat, deadlift
                }, 5));
                _workoutRepository.AddWorkout(new Workout(3, "Full body", new List <Exercise>()
                {
                    benchPress, militaryPress, squat, deadlift
                }, 3));

                _workoutRepository.AddWorkoutToHistory(new Workout(1, "Upper body", new List <Exercise>()
                {
                    benchPress, militaryPress
                }, 4), "00:44:23", "20.01.2020", 342, new List <int>()
                {
                    10, 10, 9, 9, 10, 10, 10, 9
                }, new List <int>()
                {
                    90, 95, 100, 100, 70, 70, 75, 75
                });

                _weightMeasureRepository.AddWeightMeasure(new WeightMeasure(1, 103.5, 90.0, "10.01.2020"));
                _weightMeasureRepository.AddWeightMeasure(new WeightMeasure(2, 102.0, 90.0, "20.01.2020"));

                _defaultModelLoaded = true;
            }
        }
Exemplo n.º 2
0
        public void Handle(AssignExerciseToWorkoutCommand command)
        {
            var exercises = _exerciseSetRepository.GetExerciseSets(command.Exercises);
            var workout   = Workout.Create();

            workout.Description = command.Description;
            workout.Exercises   = exercises;
            workout.UserId      = command.UserId;

            _workoutRepository.AddWorkout(workout);
            _exerciseSetRepository.AssignWorkout(command.Exercises, workout);
        }
Exemplo n.º 3
0
        public ActionResult Create(Workout workout)
        {
            SetUp();
            workout.User      = _user;
            workout.Fk_UserId = _user.UserId;

            ModelState.Remove("WorkoutExercises");
            if (ModelState.IsValid)
            {
                _workoutRepository.AddWorkout(workout);
                return(RedirectToAction("Index"));
            }

            return(View(workout));
        }
        public void AddNewWorkout(IAddWorkoutView form, IWorkoutRepository workoutRepository, IExerciseRepository exerciseRepository)
        {
            if (form.ConfirmAddWorkout() == true)
            {
                try
                {
                    string workoutName = form.WorkoutName;
                    int    setsPerExercise;

                    try
                    {
                        setsPerExercise = form.SetsPerExercise;
                        if (setsPerExercise < 1)
                        {
                            throw new Exception();
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Please input valid number of sets per exercise.");
                        return;
                    }

                    if (String.IsNullOrEmpty(workoutName))
                    {
                        MessageBox.Show("Please input your workout name.");
                        return;
                    }
                    List <string>   exerciseNames = form.ExerciseNames;
                    int             workoutId     = workoutRepository.GetNewId();
                    List <Exercise> exercises     = new List <Exercise>();

                    foreach (var exerciseName in exerciseNames)
                    {
                        var exercise = exerciseRepository.GetExerciseByName(exerciseName);
                        exercises.Add(exercise);
                    }
                    Workout newWorkout = new Workout(workoutId, workoutName, exercises, setsPerExercise);
                    workoutRepository.AddWorkout(newWorkout);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("EXCEPTION: " + ex.Message);
                    throw;
                }
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> AddWorkout(WorkoutForUserDTO workoutForUserDTO)
        {
            var currUser = await _profileRepo.GetUser(workoutForUserDTO.User.Id);

            currUser.Person.Weight = workoutForUserDTO.User.Weight;
            // if (workoutForUserDTO.User.Id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            //     return Unauthorized();

            Workout _workout = _mapper.Map <Workout>(workoutForUserDTO);

            _workout.PersonId = currUser.PersonId;
            _workout.Person   = currUser.Person;

            await _repo.AddWorkout(_workout);

            return(Ok(_workout));
        }
Exemplo n.º 6
0
        public HttpResponseMessage AddWorkout(AddWorkoutModelRequest objAddWorkoutModelRequest)
        {
            AddWorkoutResponseModel result = new AddWorkoutResponseModel();

            if (ModelState.IsValid)
            {
                try
                {
                    var    headers = Request.Headers;
                    string token   = headers.Authorization.Parameter.ToString();
                    Int64  UserId  = _objFriendFitDBEntity.Database.SqlQuery <Int64>("select UserId from UserToken where TokenCode={0}", token).FirstOrDefault();

                    int   value     = _objIWorkoutRepository.AddWorkout(objAddWorkoutModelRequest, UserId);
                    Int64 WorkoutId = _objFriendFitDBEntity.Database.SqlQuery <Int64>("SELECT TOP 1 Id FROM WorkOut ORDER BY id DESC").FirstOrDefault();
                    if (value > 0)
                    {
                        result.WorkoutId  = WorkoutId;
                        result.StatusCode = Convert.ToInt32(HttpStatusCode.OK);
                        result.Message    = "Workout added successfully!";
                    }
                    else
                    {
                        result.StatusCode = Convert.ToInt32(HttpStatusCode.NotAcceptable);
                        result.Message    = "Parameters are not correct";
                    }
                }
                catch (Exception ex)
                {
                    result.StatusCode = Convert.ToInt32(HttpStatusCode.BadRequest);
                    _response         = Request.CreateResponse(HttpStatusCode.InternalServerError, "Some error occurred");
                }
                _response = Request.CreateResponse(HttpStatusCode.OK, result);
            }
            else
            {
                ModelState.AddModelError("", "One or more errors occurred.");
            }
            return(_response);
        }