public WorkoutViewModel(Workout workout, FitnessTrackerDataContext dc) { dataContext = dc; Workout = workout; exerciseTypeRepository = new ExerciseTypeRepository(dataContext); DistanceUnitTypeList = CreateDistanceUnitSelectList(); }
public ActionResult Create(int workoutRegimenId) { Workout workout = new Workout() { StartingTime = DateTime.Today }; workout.WorkoutRegimenId = workoutRegimenId; return View(new WorkoutViewModel(workout, workoutRepository.DataContext)); }
public ActionResult Create(int workoutRegimenId, WorkoutViewModel wrfvmToAdd) { try { FitnessUser currentUser = workoutRepository.FindByUserName(User.Identity.Name).Single(); WorkoutRegimen parentRegimen = workoutRepository.GetWorkoutRegimen(currentUser, workoutRegimenId); wrfvmToAdd.Workout.WorkoutId = 0; // clear primary key value so that DB can create new value workoutRepository.Add(parentRegimen, wrfvmToAdd.Workout); workoutRepository.Save(); return RedirectToAction("Details", new { id = wrfvmToAdd.Workout.WorkoutId }); } catch { Workout workout = new Workout() { StartingTime = DateTime.Today }; return View(new WorkoutViewModel(workout, workoutRepository.DataContext)); } }
public void Delete(Workout workout) { DataContext.Workouts.DeleteOnSubmit(workout); }
// // Insert/Delete Methods public void Add(WorkoutRegimen regimen, Workout workout) { regimen.Workouts.Add(workout); DataContext.Workouts.InsertOnSubmit(workout); }
private void detach_Workouts(Workout entity) { this.SendPropertyChanging(); entity.DistanceUnit = null; }
partial void DeleteWorkout(Workout instance);
partial void UpdateWorkout(Workout instance);
partial void InsertWorkout(Workout instance);
private void detach_Workouts(Workout entity) { this.SendPropertyChanging(); entity.WorkoutRegimen = null; }
public Workout CreateWorkout(WorkoutRegimen workoutRegimen) { Workout workout = new Workout(); workout.WorkoutRegimen = workoutRegimen; return workout; }