コード例 #1
0
 public void Delete(FitnessUser fitnessUser, WorkoutRegimen workoutRegimen)
 {
     if (!isAssociated(fitnessUser, workoutRegimen))
         throw new ApplicationException(
             String.Format("Workout regimen #{0} does not belong to user #{1}.", workoutRegimen.WorkoutRegimenId, fitnessUser.FitnessUserId)
         );
     DataContext.WorkoutRegimens.DeleteOnSubmit(workoutRegimen);
 }
コード例 #2
0
 public Workout GetWorkout(FitnessUser fitnessUser, int workoutRegimenId, int workoutId)
 {
     IQueryable<Workout> workoutQuery = FindAllWorkoutsByUser(fitnessUser).Where(
         w => (w.WorkoutRegimenId == workoutRegimenId) &&
              (w.WorkoutRegimen.FitnessUserId == fitnessUser.FitnessUserId)
     );
     return workoutQuery.SingleOrDefault(d => d.WorkoutId == workoutId);
 }
コード例 #3
0
 // Checks if user exists, and adds if non-existant
 public void AddUserByNameIfNotExists(string userName)
 {
     if (FindByUserName(userName).ToList().Count() == 0)
     {
         FitnessUser fitnessUser = new FitnessUser();
         fitnessUser.UserName = userName;
         fitnessUser.DateCreated = DateTime.Now;
         fitnessUser.DateLastVisited = DateTime.Now;
         Add(fitnessUser);
     }
 }
コード例 #4
0
 public void Delete(FitnessUser fitnessUser)
 {
     DataContext.FitnessUsers.DeleteOnSubmit(fitnessUser);
 }
コード例 #5
0
 //
 // Insert/Delete Methods
 public void Add(FitnessUser fitnessUser)
 {
     DataContext.FitnessUsers.InsertOnSubmit(fitnessUser);
 }
コード例 #6
0
 public IQueryable<Workout> FindAllWorkoutsByUserAndRegimen(FitnessUser fitnessUser, WorkoutRegimen regimen)
 {
     return DataContext.Workouts.Where(w => (w.WorkoutRegimen.FitnessUserId == fitnessUser.FitnessUserId) &&
                                            (w.WorkoutRegimenId == regimen.WorkoutRegimenId));
 }
コード例 #7
0
 //
 // Query Methods
 public IQueryable<Workout> FindAllWorkoutsByUser(FitnessUser fitnessUser)
 {
     return DataContext.Workouts.Where(w => (w.WorkoutRegimen.FitnessUserId == fitnessUser.FitnessUserId));
 }
コード例 #8
0
 partial void DeleteFitnessUser(FitnessUser instance);
コード例 #9
0
 partial void UpdateFitnessUser(FitnessUser instance);
コード例 #10
0
 partial void InsertFitnessUser(FitnessUser instance);
コード例 #11
0
 //
 // Insert/Delete Methods
 public bool isAssociated(FitnessUser fitnessUser, WorkoutRegimen workoutRegimen)
 {
     return (fitnessUser.WorkoutRegimens.Where(
         wr => (wr.WorkoutRegimenId == workoutRegimen.WorkoutRegimenId)
     ).ToList().Count() > 0);
 }
コード例 #12
0
 public WorkoutRegimen GetWorkoutRegimen(FitnessUser fitnessUser, int id)
 {
     var wrbu = FindAllWorkoutRegimensByUser(fitnessUser);
     return wrbu.SingleOrDefault(d => d.WorkoutRegimenId == id);
 }
コード例 #13
0
 public IQueryable<WorkoutRegimen> FindByExerciseType(FitnessUser fitnessUser, ExerciseType exerciseType)
 {
     var wrbu = FindAllWorkoutRegimensByUser(fitnessUser);
     return wrbu.Where(wr => (wr.ExerciseTypeId == exerciseType.ExerciseTypeId));
 }
コード例 #14
0
 public IQueryable<WorkoutRegimen> FindAllFinishedWorkoutRegimens(FitnessUser fitnessUser, DateTime dateTime)
 {
     var wrbu = FindAllWorkoutRegimensByUser(fitnessUser);
     return wrbu.Where(wr => (wr.StartDate.AddDays(7 * wr.NumWeeks) < dateTime));
 }
コード例 #15
0
 public IQueryable<WorkoutRegimen> FindAllCurrentWorkoutRegimensByDate(FitnessUser fitnessUser, DateTime dateTime)
 {
     var wrbu = FindAllWorkoutRegimensByUser(fitnessUser);
     return wrbu.Where(wr => ((wr.StartDate <= dateTime) &&
                              (wr.StartDate.AddDays(7 * wr.NumWeeks) >= dateTime)));
 }
コード例 #16
0
 public void Add(FitnessUser fitnessUser, WorkoutRegimen workoutRegimen)
 {
     fitnessUser.WorkoutRegimens.Add(workoutRegimen);
     DataContext.WorkoutRegimens.InsertOnSubmit(workoutRegimen);
 }