// GET: Exercises/GetDetails/5 public async Task <ActionResult> GetDetails(int id) { var user = await userManager.FindByIdAsync(User.Identity.GetUserId()); if (user == null) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } var exercises = exerciseTypeService.Find(e => e.ApplicationUser.Id == user.Id && e.Id == id).ToList(); if (exercises.Count == 0) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var viewModel = new EditExerciseTypeViewModel() { Id = exercises.FirstOrDefault().Id, Name = exercises.FirstOrDefault().Name, Description = exercises.FirstOrDefault().Description, IsFavorite = exercises.FirstOrDefault().IsFavorite }; return(PartialView("_EditPartial", viewModel)); }
private Workout GetPreparedWorkoutTemplate2(ApplicationUser user, ExerciseTypeService ets) { var workout = new Workout(); workout.ApplicationUser = user; workout.WorkoutDate = DateTime.Today; workout.Exercises = new List <Exercise>(); for (int j = 0; j < 6; j++) { var exercise = new Exercise(); exercise.ExerciseType = ets.Find( e => e.ApplicationUser == user && e.Name == InitialData.Exercises[j + 4].Comment). ToList().FirstOrDefault(); //exercise.Workout = workout; exercise.Sets = new List <Set>(); foreach (var s in InitialData.Exercises[j + 4].Sets) { exercise.Sets.Add(new Set { Weight = s.Weight, Repetitions = s.Repetitions //Exercise = exercise }); } workout.Exercises.Add(exercise); } workout.Exercises.ToList()[0].Comment = ""; workout.Exercises.ToList()[1].Comment = "Зменшити амплітуду руху"; workout.Exercises.ToList()[2].Comment = "Спробувати підвісити додаткову вагу"; workout.Exercises.ToList()[3].Comment = ""; workout.Exercises.ToList()[4].Comment = ""; workout.Exercises.ToList()[5].Comment = ""; return(workout); }
private Workout GetPreparedWorkoutTemplate1(ApplicationUser user, ExerciseTypeService ets) { var workout = new Workout(); workout.ApplicationUser = user; workout.WorkoutDate = DateTime.Today; workout.Exercises = new List <Exercise>(); for (int j = 0; j < 5; j++) { var exercise = new Exercise(); exercise.ExerciseType = ets.Find( e => e.ApplicationUser == user && e.Name == InitialData.Exercises[j].Comment). ToList().FirstOrDefault(); //exercise.Workout = workout; exercise.Sets = new List <Set>(); foreach (var s in InitialData.Exercises[j].Sets) { exercise.Sets.Add(new Set { Weight = s.Weight, Repetitions = s.Repetitions //Exercise = exercise }); } workout.Exercises.Add(exercise); } workout.Exercises.ToList()[0].Comment = "Не ставити руки надто вузько"; workout.Exercises.ToList()[1].Comment = "Не торкатися голови"; workout.Exercises.ToList()[2].Comment = "Не забути пояс"; workout.Exercises.ToList()[3].Comment = "Слідкувати за спиною"; workout.Exercises.ToList()[4].Comment = ""; return(workout); }