//public WorkoutsViewModel()
        //{
        //    //Workouts = new ObservableCollection<Workout>();
        //    //LoadWorkoutsCommand = new Command(ExecuteLoadWorkoutsCommand);
        //}

        public WorkoutsViewModel(MainPageViewModel parent)
        {
            _parent = parent;
            _gasWorkoutsController = _parent._gasContextController.GasWorkoutsController;
            Workouts            = new ObservableCollection <Workout>();
            LoadWorkoutsCommand = new Command(ExecuteLoadWorkoutsCommand);
        }
Ejemplo n.º 2
0
 public AddWorkoutViewModel(MainPageViewModel parent)
 {
     _parent = parent;
     // SaveWorkoutCommand = new Command(SaveWorkout);   // could use command like this if SaveWorkout was not a task
     SaveWorkoutCommand = new Command(
         async() => await SaveWorkout(),
         () => !IsBusy
         );
     _gasUsersController    = _parent._gasContextController.GasUsersController;
     _gasWorkoutsController = _parent._gasContextController.GasWorkoutsController;
 }
 public CompetitorWorkoutDetailsPageViewModel(Workout workout)
 {
     _workout     = workout;
     _date        = _workout.GetDate;
     _description = _workout.Description;
     using (GasContext context = new GasContext())
     {
         context.SetupServer();
         GasContextController contextController = new GasContextController(context);
         GasUsersController   usersController   = contextController.GasUsersController;
         _user = usersController.FindGasUser(_workout.GasUserId);
         _competitorUsername = _user.Username;
         GasWorkoutsController workoutsController = contextController.GasWorkoutsController;
         _workout.Workouts = workoutsController.GetWorkoutsWorkoutTypes(_workout.WorkoutId).ToList();
     }
 }
Ejemplo n.º 4
0
 private ObservableCollection<Workout> GetFriendsWorkouts()
 {
     using (GasContext context = new GasContext())
     {
         context.SetupServer();
         GasContextController contextController = new GasContextController(context);
         GasWorkoutsController workoutsController = contextController.GasWorkoutsController;
         IList<Workout> friendsWorkouts = workoutsController.GetUsersWorkouts(_friend.UserId).ToList();
         friendsWorkouts = friendsWorkouts.OrderBy(w => w.Date).ToList();
         IList<Workout> sortedWorkouts = friendsWorkouts.Reverse().ToList();
         if (sortedWorkouts.Count == 0)
         {
             NoWorkoutsLabelVisibility = true;
         }
         else
         {
             NoWorkoutsLabelVisibility = false;
         }
         return new ObservableCollection<Workout>(sortedWorkouts);
     }
 }