Exemplo n.º 1
0
        public ActionResult Create(Exercise exercise)
        {
            if (ModelState.IsValid)
            {
                _repository.AddExercise(exercise);
                return(RedirectToAction("Index"));
            }

            return(View(exercise));
        }
        public HttpResponseMessage AddExercise(AddExerciseRequestModel objAddExerciseRequestModel)
        {
            FResponse result = new FResponse();

            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 = _objIExerciseRepository.AddExercise(objAddExerciseRequestModel);
                if (value > 0)
                {
                    result.WorkoutId  = objAddExerciseRequestModel.WorkOutId;
                    result.StatusCode = Convert.ToInt32(HttpStatusCode.OK);
                    result.Message    = "Exercise added successfully!";
                }
                else
                {
                    result.WorkoutId  = objAddExerciseRequestModel.WorkOutId;
                    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);

            return(_response);
        }
        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.º 4
0
 public void AddExercise(Exercise exercise, IExerciseRepository exerciseRepository)
 {
     try
     {
         exerciseRepository.AddExercise(exercise);
     }
     catch (NameAlreadyTakenException nameEx)
     {
         throw nameEx;
     }
 }
Exemplo n.º 5
0
        public async Task AddExercise(Exercise exercise)
        {
            if (exercise == null)
            {
                Console.WriteLine("bad argument");
                throw new ArgumentNullException(nameof(exercise));
            }

            Console.WriteLine("repository");
            await _exerciseRepository.AddExercise(exercise);
        }
        public IActionResult AddExercise(Exercise exercise)
        {
            if (exercise == null)
            {
                return(BadRequest());
            }

            _exerciseRepository.AddExercise(exercise);

            return(Ok(exercise));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> AddExercise(ExerciseForAddDto exerciseForAdd)
        {
            exerciseForAdd.Name = exerciseForAdd.Name.ToLower();
            if (await _repo.ExerciseExists(exerciseForAdd.Name))
            {
                return(BadRequest("Exercise already Exists"));
            }
            var exerciseToCreate = _mapper.Map <Exercise>(exerciseForAdd);
            var createdExercise  = await _repo.AddExercise(exerciseToCreate);

            var exerciseForreturn = _mapper.Map <ExerciseForDetailDto>(createdExercise);

            return(CreatedAtRoute("GetExercise", new{ Controller = "Exercise", Id = createdExercise.Id }, exerciseForreturn));
        }
Exemplo n.º 8
0
        public int AddExercise(NewExerciseVm newExerciseVm)
        {
            var exerciseType = _exerciseTypeRepo.GetExerciseTypeById(newExerciseVm.ExerciseTypeId);

            var exercise = new Exercise
            {
                Id             = newExerciseVm.Id,
                Name           = newExerciseVm.Name,
                ExerciseType   = exerciseType,
                ExerciseTypeId = exerciseType.Id
            };

            _exerciseRepo.AddExercise(exercise);

            return(exercise.Id);
        }
Exemplo n.º 9
0
        public void Handle(AddExerciseCommand command)
        {
            var exerciseCategory = _exerciseRepository.GetExerciseCategory(command.ExerciseCategoryId);
            var exerciseMode     = _exerciseRepository.GetExerciseMode(command.ExerciseModeId);

            try
            {
                var exercise = new Exercise(
                    command.Name,
                    command.Desc,
                    exerciseCategory,
                    exerciseMode
                    );
                _exerciseRepository.AddExercise(exercise);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
                //TODO throw own Exception
            }
        }
Exemplo n.º 10
0
        public async Task <IActionResult> AddExercise(MakeOrUpdateExerciseVM makeExerciseVM)
        {
            int id = await exerciseRepository.AddExercise(makeExerciseVM);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 11
0
        public Exercise AddExercise(Exercise item)
        {
            _repository.AddExercise(item);

            return(item);
        }
Exemplo n.º 12
0
        public void LoadDefaultModel()
        {
            if (isDefaultModelLoaded == false)
            {
                try
                {
                    Exercise exercise1 = new Exercise("Čučnjevi", FitnessLevel.Beginner, "Opis čučnjeva");
                    Exercise exercise2 = new Exercise("Sklekovi", FitnessLevel.Intermediate, "Opis sklekova");
                    Exercise exercise3 = new Exercise("Plank", FitnessLevel.Beginner, "Opis planka");
                    Exercise exercise4 = new Exercise("Ruski čučnjevi", FitnessLevel.Advanced, "Opis ruskih čučnjeva");
                    Exercise exercise5 = new Exercise("Bočni plank", FitnessLevel.Intermediate, "Opis bočnog planka");
                    Exercise exercise6 = new Exercise("Podizanja trupa", FitnessLevel.Intermediate, "Opis podizanja trupa");

                    exerciseRepository.AddExercise(exercise1);
                    exerciseRepository.AddExercise(exercise2);
                    exerciseRepository.AddExercise(exercise3);
                    exerciseRepository.AddExercise(exercise4);
                    exerciseRepository.AddExercise(exercise5);
                    exerciseRepository.AddExercise(exercise6);

                    Training training1 = new Training("Trening funkcionalne snage", FitnessLevel.Beginner,
                                                      new List <Exercise> {
                        exercise1, exercise2, exercise3
                    });
                    Training training2 = new Training("Napredni trening funkcionalne snage", FitnessLevel.Advanced,
                                                      new List <Exercise> {
                        exercise1, exercise2, exercise3, exercise4, exercise5, exercise6
                    });

                    trainingRepository.AddTraining(training1);
                    trainingRepository.AddTraining(training2);

                    TrainingPeriod trainingPeriod1 = new TrainingPeriod(DayOfWeek.Monday, new TimeSpan(17, 0, 0),
                                                                        new TimeSpan(18, 0, 0));
                    TrainingPeriod trainingPeriod2 = new TrainingPeriod(DayOfWeek.Tuesday, new TimeSpan(17, 0, 0),
                                                                        new TimeSpan(18, 0, 0));
                    TrainingPeriod trainingPeriod3 = new TrainingPeriod(DayOfWeek.Wednesday, new TimeSpan(17, 0, 0),
                                                                        new TimeSpan(18, 0, 0));
                    TrainingPeriod trainingPeriod4 = new TrainingPeriod(DayOfWeek.Thursday, new TimeSpan(17, 0, 0),
                                                                        new TimeSpan(18, 0, 0));
                    TrainingPeriod trainingPeriod5 = new TrainingPeriod(DayOfWeek.Friday, new TimeSpan(17, 0, 0),
                                                                        new TimeSpan(18, 0, 0));
                    TrainingPeriod trainingPeriod6 = new TrainingPeriod(DayOfWeek.Saturday, new TimeSpan(17, 0, 0),
                                                                        new TimeSpan(18, 0, 0));
                    TrainingPeriod trainingPeriod7 = new TrainingPeriod(DayOfWeek.Sunday, new TimeSpan(17, 0, 0),
                                                                        new TimeSpan(18, 0, 0));

                    trainingPeriodRepository.AddTrainingPeriod(trainingPeriod1);
                    trainingPeriodRepository.AddTrainingPeriod(trainingPeriod2);
                    trainingPeriodRepository.AddTrainingPeriod(trainingPeriod3);
                    trainingPeriodRepository.AddTrainingPeriod(trainingPeriod4);
                    trainingPeriodRepository.AddTrainingPeriod(trainingPeriod5);
                    trainingPeriodRepository.AddTrainingPeriod(trainingPeriod6);
                    trainingPeriodRepository.AddTrainingPeriod(trainingPeriod7);

                    TrainingGroup trainingGroup1 = new TrainingGroup("Početnička grupa", training1,
                                                                     new List <TrainingPeriod> {
                        trainingPeriod2, trainingPeriod4
                    }, 200.00M);
                    TrainingGroup trainingGroup2 = new TrainingGroup("Napredna grupa", training2,
                                                                     new List <TrainingPeriod> {
                        trainingPeriod1, trainingPeriod3, trainingPeriod5
                    }, 300.00M);

                    trainingGroupRepository.AddTrainingGroup(trainingGroup1);
                    trainingGroupRepository.AddTrainingGroup(trainingGroup2);

                    Client client1 = new Client("12938549201", "Ivana", "Marković", new DateTime(1981, 1, 8), "0912728274",
                                                new DateTime(2020, 2, 10), FitnessLevel.Beginner, "Ima problema s koljenima",
                                                new List <TrainingGroup> {
                        trainingGroup1
                    });
                    Client client2 = new Client("52932999221", "Đorđe", "Ivanović", new DateTime(1991, 5, 20), "0981827364",
                                                new DateTime(2020, 9, 5), FitnessLevel.Advanced, "",
                                                new List <TrainingGroup> {
                        trainingGroup1, trainingGroup2
                    });
                    Client client3 = new Client("29375948378", "Josip", "Cvitković", new DateTime(1995, 10, 15), "0913819204",
                                                new DateTime(2020, 10, 10), FitnessLevel.Advanced, "",
                                                new List <TrainingGroup> {
                        trainingGroup2
                    });
                    Client client4 = new Client("10382960594", "Sara", "Praputak", new DateTime(1998, 4, 25), "0998278477",
                                                new DateTime(2021, 1, 11), FitnessLevel.Beginner, "Ima problema s leđima",
                                                new List <TrainingGroup> {
                        trainingGroup1
                    });
                    Client client5 = new Client("10283953829", "Ivona", "Malenica", new DateTime(1997, 12, 12), "0919287782",
                                                new DateTime(2021, 1, 15), FitnessLevel.Beginner, "",
                                                new List <TrainingGroup> {
                        trainingGroup1
                    });

                    clientRepository.AddClient(client1);
                    clientRepository.AddClient(client2);
                    clientRepository.AddClient(client3);
                    clientRepository.AddClient(client4);
                    clientRepository.AddClient(client5);

                    ClientDebt clientDebt1 = new ClientDebt(client1, 200.00M, "Članarina za studeni 2020 (Početna grupa)");
                    ClientDebt clientDebt2 = new ClientDebt(client1, 200.00M, "Članarina za prosinac 2020 (Početna grupa)");
                    ClientDebt clientDebt3 = new ClientDebt(client2, 200.00M, "Članarina za prosinac 2020 (Početna grupa)");
                    ClientDebt clientDebt4 = new ClientDebt(client2, 300.00M, "Članarina za prosinac 2020 (Napredna grupa)");
                    ClientDebt clientDebt5 = new ClientDebt(client3, 300.00M, "Članarina za prosinac 2020 (Napredna grupa)");
                    ClientDebt clientDebt6 = new ClientDebt(client4, 200.00M, "Članarina za prosinac 2020 (Početna grupa)");
                    ClientDebt clientDebt7 = new ClientDebt(client5, 200.00M, "Članarina za prosinac 2020 (Početna grupa)");

                    clientDebtRepository.AddClientDebt(clientDebt1);
                    clientDebtRepository.AddClientDebt(clientDebt2);
                    clientDebtRepository.AddClientDebt(clientDebt3);
                    clientDebtRepository.AddClientDebt(clientDebt4);
                    clientDebtRepository.AddClientDebt(clientDebt5);
                    clientDebtRepository.AddClientDebt(clientDebt6);
                    clientDebtRepository.AddClientDebt(clientDebt7);

                    isDefaultModelLoaded = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }