Ejemplo n.º 1
0
 public static Workout LoadById(Guid id)
 {
     try
     {
         using (AmbrosiaEntities dc = new AmbrosiaEntities())
         {
             tblWorkout row = dc.tblWorkouts.FirstOrDefault(g => g.Id == id);
             if (row != null)
             {
                 Workout workout = new Workout
                 {
                     Id          = row.Id,
                     WorkoutType = WorkoutTypeManager.LoadById(row.WorkoutTypeId),
                     StartTime   = row.StartTime,
                     EndTime     = row.EndTime,
                     UserId      = row.UserId
                 };
                 return(workout);
             }
             else
             {
                 throw new Exception("Row was not found!");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 public static List <Workout> Load(Guid userId)
 {
     //Retrieve all the rows in a list
     try
     {
         List <Workout> rows = new List <Workout>();
         using (AmbrosiaEntities dc = new AmbrosiaEntities())
         {
             dc.tblWorkouts
             .Where(w => w.UserId == userId)
             .ToList()
             .ForEach(g => rows.Add(new Workout
             {
                 Id          = g.Id,
                 WorkoutType = WorkoutTypeManager.LoadById(g.WorkoutTypeId),
                 StartTime   = g.StartTime,
                 EndTime     = g.EndTime,
                 UserId      = g.UserId
             }));
             return(rows);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }