private async void OpenAddMuscleDialogAsync()
        {
            var exercisedMuscle = new ExercisedMuscle
            {
                RelativeEngagement = 100d
            };

            var dialog = _dialogs.For <AddExercisedMuscleDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "Add a muscle";
            dialog.Data.SubmitButtonTitle = "Select";
            dialog.Data.AvailableMuscles  = _availableMuscles.Where(IsMuscleAvailable);
            dialog.Data.ExercisedMuscle   = ExercisedMuscleViewModel.FromModel(exercisedMuscle);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            exercisedMuscle = dialog.Data.ExercisedMuscle.ToModel();

            Exercise.Muscles.Add(exercisedMuscle);
            Exercise.Muscles.Refresh(exercisedMuscle);
            OpenAddMuscleDialogCommand.RaiseCanExecuteChanged();
        }
Exemple #2
0
        private async void OpenAddSessionDialogAsync()
        {
            var bodyweight = _trainingSessionService.GetLastUsedBodyweight() ?? 0;

            var trainingSession = new TrainingSession
            {
                Date       = DateTime.Now,
                Bodyweight = bodyweight
            };

            var dialog = _dialogs.For <TrainingSessionDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New session";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.TrainingSession   = TrainingSessionViewModel.FromModel(trainingSession);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            trainingSession = dialog.Data.TrainingSession.ToModel();
            TrainingSessions.Add(trainingSession);
            _trainingSessionService.Create(trainingSession);
        }
        private async void OpenAddSessionExerciseDialogAsync()
        {
            var exercise = new SessionExercise();

            var dialog = _dialogs.For <SessionExerciseDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New session exercise";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.SessionExercise   = SessionExerciseViewModel.FromModel(exercise);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            exercise = dialog.Data.SessionExercise.ToModel();
            TrainingSession.Exercises.Add(exercise);
        }
        private async void OpenAddMealDialogAsync()
        {
            var meal   = new MealTemplate();
            var dialog = _dialogs.For <MealDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New meal";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.Meal = MealViewModel.FromModel(meal);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            meal = dialog.Data.Meal.ToModel();
            Meals.Add(meal);
            _mealRepository.Create(meal);
        }
        private async void OpenCreateMuscleDialogAsync()
        {
            var muscle = new Muscle();

            var dialog = _dialogs.For <MuscleDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New muscle";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.Muscle            = MuscleViewModel.FromModel(muscle);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            muscle = dialog.Data.Muscle.ToModel();
            Muscles.Add(muscle);
            _muscleRepository.Create(muscle);
        }
Exemple #6
0
        private async void OpenAddCategoryDialogAsync()
        {
            var category = new Category();

            var dialog = _dialogs.For <CategoryDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New category";
            dialog.Data.SubmitButtonTitle = "Create";
            //    Order required ..
            dialog.Data.CategoryOptions = _options;
            dialog.Data.Category        = CategoryViewModel.FromModel(category, GetOption);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            category = dialog.Data.Category.ToModel();
            Categories.Add(category);
            CreateCategory(category);
        }
        private async void OpenAddUnitDialogAsync()
        {
            var unit = new FoodUnit
            {
                Grams = FoodUnitConstants.MinimumAllowedUnitGrams
            };

            var dialog = _dialogs.For <FoodUnitDialogViewModel>(FoodDialogDialogsIdentifier);

            dialog.Data.FoodUnit          = FoodUnitViewModel.FromModel(unit);
            dialog.Data.DialogTitle       = "New food unit";
            dialog.Data.SubmitButtonTitle = "Create";

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            unit = dialog.Data.FoodUnit.ToModel();
            Food.Units.Add(unit);
        }
        private async void OpenAddMealFoodDialogAsync()
        {
            var mealFood = new MealFood
            {
                Amount = 1d
            };

            var dialog = _dialogs.For <MealFoodDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New meal food";
            dialog.Data.SubmitButtonTitle = "Add";
            dialog.Data.MealFood          = MealFoodViewModel.FromModel(mealFood);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            mealFood = dialog.Data.MealFood.ToModel();
            Meal.Foods.Add(mealFood);
        }
Exemple #9
0
        private async void OpenAddFoodDialogAsync()
        {
            var food = new Food();

            food.DefaultFoodUnit.FoodUnit.Grams = FoodUnitConstants.DefaultUnitGrams;
            food.DefaultFoodUnit.FoodUnit.Name  = FoodUnitConstants.DefaultUnitName;

            var dialog = _dialogs.For <FoodDialogViewModel>(DialogsIdentifier);

            dialog.Data.Food              = FoodViewModel.FromModel(food);
            dialog.Data.DialogTitle       = "New food";
            dialog.Data.SubmitButtonTitle = "Create";

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            food = dialog.Data.Food.ToModel();
            Foods.Add(food);
            _foodService.Create(food);
        }
Exemple #10
0
        private async void OpenAddDayMealDialogAsync()
        {
            var meal = new DayMeal
            {
                Hour = DateTime.Today.Hour
            };

            var dialog = _dialogs.For <DayMealDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New meal";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.DayMeal           = DayMealViewModel.FromModel(meal);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            meal = dialog.Data.DayMeal.ToModel();
            EatingDay.Meals.Add(meal);
            EatingDay.Meals.Refresh(meal);
        }
        private async void OpenCreateExerciseDialogAsync()
        {
            var exercise = new Exercise
            {
                ContractionType = ContractionType.Dynamic,
            };

            var dialog = _dialogs.For <ExerciseDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New exercise";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.Exercise          = ExerciseViewModel.FromModel(exercise);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            exercise = dialog.Data.Exercise.ToModel();
            Exercises.Add(exercise);
            _exerciseRepository.Create(exercise);
        }
Exemple #12
0
        private async void OpenAddEatingDayDialogAsync()
        {
            var day = new EatingDay
            {
                Date = DateTime.Today
            };

            var dialog = _dialogs.For <EatingDayDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New day";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.EatingDay         = EatingDayViewModel.FromModel(day);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            day = dialog.Data.EatingDay.ToModel();
            Days.Add(day);
            _eatingDayRepository.Create(day);
        }