private async Task AddWorkout() { if (_workout.Workout_Name is null) { await Application.Current.MainPage.DisplayAlert("Error", "Please Enter the Workout Name", "OK"); return; } else { _workoutRepository = new WorkoutRepository(); _workoutDaysRepository = new WorkoutDaysRepository(); _exerciseRepository = new ExerciseRepository(); _workoutWeeksrepository = new WorkoutWeeksRepository(); Workouts oLastWorkout = await _workoutRepository.AddWorkout(_workout); foreach (var item in _weeksList) { var weekId = await _workoutWeeksrepository.AddWorkoutWeek(new WorkoutWeeks { Week = item.Week, Workout_Id = oLastWorkout.Workout_id }); foreach (var item2 in item.Days) { var dayId = await _workoutDaysRepository.AddWorkoutDay(new WorkoutDays { Day = item2.Day.ToString(), Workout_Week_Id = weekId.Id, Workout_Id = oLastWorkout.Workout_id }); foreach (var item3 in item2.exercisesOnDays) { await _exerciseRepository.AddExercise(new Exercises { Day_Id = dayId.Id, Exercise_Name = item3.ExerciseId, Sets = item3.Reps, Reps = item3.Reps, Workout_Id = oLastWorkout.Workout_id }); } } } await _navigation.PopAsync(); } }
static void Main(string[] args) { ExerciseRepository ERepo = new ExerciseRepository(); var EList = ERepo.GetAllExercises(); foreach (var item in EList) { Console.WriteLine($"{item.Name}, written in {item.Language}"); } Exercise newExercise = new Exercise() { Name = "Food", Language = "JS" }; ERepo.AddExercise(newExercise); var EJSList = ERepo.GetAllJSExercises(); foreach (var item in EJSList) { Console.WriteLine($"{item.Name}, written in {item.Language}"); } }
public void AddExercise_AddsNewExercise() { // Act var exercises = _exerciseRepository.GetAllExercises(); // Assert Assert.Equal(8, exercises.Count); // Act Exercise dumbbellFly = new Exercise(9, "Dumbbell fly", MuscleGroup.CHEST, "Lie down on a regular bench with dumbbells in your hands. Raise the dumbbells above your chest and then lower them out to your sides. Raise the dumbbells back to starting position.", "dumbbell_fly"); _exerciseRepository.AddExercise(dumbbellFly); exercises = _exerciseRepository.GetAllExercises(); // Assert Assert.Equal(9, exercises.Count); }
private void PrepareData() { _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"); _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"); _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"); _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"); _exerciseRepository.AddExercise(_benchPress); _exerciseRepository.AddExercise(_militaryPress); _exerciseRepository.AddExercise(_squat); _exerciseRepository.AddExercise(_deadlift); _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 }); }
public ActionResult AddExercise(ExerciseViewModel exerciseViewModel) { if (ModelState.IsValid) { var patient = patientRepository.GetPatientById(exerciseViewModel.PatientId); exerciseRepository.AddExercise(new Exercise() { Angle = exerciseViewModel.Angle, Description = exerciseViewModel.Description, Duration = exerciseViewModel.Duration, NumberOfRepetitions = exerciseViewModel.NumberOfRepetitions, PatientId = exerciseViewModel.PatientId, Patient = patient, AdditionalInformation = exerciseViewModel.AdditionalInformations }); exerciseRepository.Complete(); return(RedirectToAction("PatientExersicesList", new { patientId = exerciseViewModel.PatientId })); } return(View(exerciseViewModel)); }
public ViewResult WorkoutForm(Exercise exercise) { ExerciseRepository.AddExercise(exercise); return(View("Added", exercise)); }
public static void UpdateRepositories(TestContext context) { // Ako repozitoriji nisu napunjeni if (clientDebtRepository.GetAllClientDebts().Count == 0) { 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); } }
static void Main(string[] args) { //Exercise var exerciseRepo = new ExerciseRepository(); var allExercises = exerciseRepo.GetAllExercises(); Console.WriteLine("All Exercises--"); foreach (var exercise in allExercises) { Console.WriteLine($"{exercise.Name} id-{exercise.Id}"); } Console.WriteLine("------------------"); //Filter Exercise Console.WriteLine("Find exercises by language?"); var filterLanguage = Console.ReadLine(); var filteredExercise = exerciseRepo.GetFilteredExercises(filterLanguage); Console.WriteLine("All Filtered Exercises--"); foreach (var exercise in filteredExercise) { Console.WriteLine($"{exercise.Name} - {exercise.Language}"); } Console.ReadLine(); Console.WriteLine("------------------"); //Add Exercise var newExercise = new Exercise(); Console.WriteLine("What exercise do you want to add?"); newExercise.Name = Console.ReadLine(); Console.WriteLine("What language do you have to work?"); newExercise.Language = Console.ReadLine(); exerciseRepo.AddExercise(newExercise); Console.WriteLine("------------------"); //Instructor with Cohort var instructorRepo = new InstructorRepository(); var allInstructors = instructorRepo.GetAllIntructors(); Console.WriteLine("All Intructors with cohort--"); foreach (var instructor in allInstructors) { Console.WriteLine($"{instructor.FirstName} {instructor.LastName} is the instructor for {instructor.Cohort.Name}"); } Console.WriteLine("------------------"); //Add Instructor var newInstructor = new Instructor(); Console.WriteLine("What is your new instructor first name?"); newInstructor.FirstName = Console.ReadLine(); Console.WriteLine("What is your new instructor last name?"); newInstructor.LastName = Console.ReadLine(); Console.WriteLine("What is your new instructor slack handle?"); newInstructor.SlackHandle = Console.ReadLine(); Console.WriteLine("Where is your new instructor assigned?"); newInstructor.Cohort.Id = Convert.ToInt32(Console.ReadLine()); instructorRepo.AddInstructor(newInstructor); Console.WriteLine("------------------"); //List Of Students var studentRepo = new StudentRepository(); var allStudents = studentRepo.GetAllStudents(); Console.WriteLine("List of Students------"); foreach (var student in allStudents) { Console.WriteLine($"{student.FirstName} {student.LastName} who's (id) is {student.Id} is in {student.Cohort.Name}"); } Console.WriteLine("------------------"); //Student by Id Console.WriteLine("Enter student id to choose student"); var studentById = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter exercise id to choose student"); var exerciseById = Convert.ToInt32(Console.ReadLine()); studentRepo.AddExercise(studentById, exerciseById); Console.ReadLine(); Console.WriteLine("------------------"); // Get all exercise by StudentId Console.WriteLine("Choose Student By Id"); var studentWithExercise = Convert.ToInt32(Console.ReadLine()); var studentWithExercises = studentRepo.GetStudentById(studentWithExercise); foreach (var studentExercise in studentWithExercises.Exercise) { Console.WriteLine($"{studentWithExercises.FirstName} {studentWithExercises.LastName} in {studentWithExercises.Cohort.Name} is working on {studentExercise.Name}"); } Console.ReadLine(); }