コード例 #1
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Workouts.Clear();
                var workouts = await DataStore.GetWorkoutAsync(true);

                foreach (var workout in workouts)
                {
                    Workouts.Add(workout);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #2
0
        public WorkoutManagerViewModel()
        {
            Add = new Command(async() =>
            {
                await navigation_.PushAsync(new WorkoutCreation());
                await RefreshList();
            });

            Edit = new Command <object>(async w =>
            {
                var workout = Workouts.First(e => e == w);
                await workout.Edit(database_);
                Workouts.Remove(workout);
                Workouts.Add(await database_.GetWorkout(workout.Id, workout.WorkoutType));
            });

            Delete = new Command <object>(async w =>
            {
                var workout = (IWorkout)w;
                if (await AskQuestion("Delete " + workout.Title + " is permament"))
                {
                    Workouts.Remove(workout);
                    await workout.RemoveFrom(database_);
                }
            });
        }
コード例 #3
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Workouts.Clear();
                var workouts = await DataStore.GetItemsAsync(true);

                foreach (var item in workouts)
                {
                    Workouts.Add(item);
                }
                var exercises = await exerciseStore.GetItemsAsync(true);

                foreach (var item in exercises)
                {
                    Exercises.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #4
0
        public async Task LoadAsync()
        {
            var lookup = await _clientLookupService.GetClientLookupAsync();

            Clients.Clear();
            foreach (var item in lookup)
            {
                Clients.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, _eventAggregator, nameof(ClientDetailViewModel)));
            }

            lookup = await _workoutLookupService.GetWorkoutLookupAsync();

            Workouts.Clear();
            foreach (var item in lookup)
            {
                Workouts.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, _eventAggregator, nameof(WorkoutDetailViewModel)));
            }

            lookup = await _exerciseLookupDataService.GetExerciseLookupAsync();

            Exercises.Clear();
            foreach (var item in lookup)
            {
                Exercises.Add(new NavigationItemViewModel(item.Id, item.DisplayMember, _eventAggregator, nameof(ExerciseDetailViewModel)));
            }
        }
コード例 #5
0
ファイル: MainViewModel.cs プロジェクト: dpetrovych/gymme
        private void LoadWorkouts()
        {
            Workouts.Clear();
            foreach (var workout in RepoWorkout.Instance.FindAll())
            {
                Workouts.Add(new WorkoutVM(workout, this));
            }

            NotifyPropertyChanged("IsWorkoutsEmpty");
        }
コード例 #6
0
        public void ReadWorkouts()
        {
            // Summary
            //
            // Read workouts from Database with DbHelper class. Clear existing workouts first.

            var workouts = MongoHelper.GetWorkoutsAsync();

            Workouts.Clear();

            foreach (var workout in workouts)
            {
                Workouts.Add(workout);
            }
        }
コード例 #7
0
        private async Task LoadData()
        {
            if (_isDataLoaded)
            {
                return;
            }
            Workouts.Clear();
            _isDataLoaded = true;
            var workouts = await _workoutStore.GetWorkoutsAsync();

            foreach (var w in workouts)
            {
                Workouts.Add(w);
            }
        }
コード例 #8
0
        public async void LoadWorkouts()
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(@"http://localhost:50562/api/");

                var json = await client.GetStringAsync("Workouts");

                Workout[] workouts = JsonConvert.DeserializeObject <Workout[]>(json);

                Workouts.Clear();
                foreach (var w in workouts)
                {
                    Workouts.Add(w);
                }
            }
        }
コード例 #9
0
        public async Task LoadWorkouts()
        {
            Workouts.Clear();
            WorkoutSearchParams searchParams = new WorkoutSearchParams();

            if (WorkoutType != null)
            {
                searchParams.WorkoutType = WorkoutType.Name;
            }

            if (!string.IsNullOrEmpty(Duration))
            {
                searchParams.Duration = int.Parse(Duration);
            }

            List <Workout> workouts = await workoutApiService.GetAll <List <Workout> >(searchParams);

            foreach (var workout in workouts)
            {
                Workouts.Add(workout);
            }
        }
コード例 #10
0
        // Function for testing...
        public void InsertData()
        {
            Database.EnsureCreated();

            var user = new GasUser()
            {
                Username = "******"
            };
            var workout = new Workout()
            {
                Exercise  = "Cardio",
                Length    = 40,
                Date      = DateTime.Now,
                GasUser   = user,
                GasUserId = user.UserId
            };

            user.Workouts.Add(workout);
            GasUsers.Add(user);
            Workouts.Add(workout);

            // Saves changes
            SaveChanges();
        }