/// <summary>
        /// Delete selected workout plan and items
        /// </summary>
        /// <param name="sender">Sender button</param>
        public void WorkoutPlanDelete(object sender)
        {
            if (sender == null || !(sender is Button button))
            {
                return;
            }
            if (!(button.DataContext is WorkoutPlanItem workoutPlanItem))
            {
                return;
            }

            var dialog = new DeleteDialog();

            dialog.Closing += (send, args) =>
            {
                if (dialog.DataContext is DeleteDialogViewModel vm && vm.Result)
                {
                    using var db = new AppDbContext();
                    db.WorkoutPlans.Remove(workoutPlanItem.WorkoutPlan);
                    db.SaveChanges();

                    WorkoutPlanItems.Remove(workoutPlanItem);
                }
            };

            dialog.ShowDialogWindow(new DeleteDialogViewModel(dialog, "Delete Workout Plan", workoutPlanItem.WorkoutPlan.Title));
        }
        /// <summary>
        /// Add completed workout log
        /// </summary>
        /// <param name="sender">Sender button</param>
        public void AddWorkoutLog(object sender)
        {
            if (sender == null || !(sender is Button button))
            {
                return;
            }
            if (!(button.DataContext is WorkoutDayItem workoutDayItem))
            {
                return;
            }

            var dialog = new WorkoutLogInputDialog();

            dialog.Closing += (s, e) =>
            {
                var workoutPlanItem = WorkoutPlanItems.Single(x => x.WorkoutPlan.Id == workoutDayItem.WorkoutDay.WorkoutPlanId);

                if (workoutPlanItem != null && workoutPlanItem.WorkoutDayItems != null && workoutPlanItem.WorkoutDayItems.Count > 0)
                {
                    workoutPlanItem.WorkoutPlanCompleteCount = workoutPlanItem.WorkoutDayItems.Count(x => x.WorkoutDay.IsCompleted);

                    if (workoutPlanItem.WorkoutPlanCompleteCount > 0 && workoutPlanItem.WorkoutPlanCompleteCount == workoutPlanItem.WorkoutDayItems.Count)
                    {
                        workoutPlanItem.WorkoutPlan.IsCompleted = true;

                        using var db = new AppDbContext();
                        db.WorkoutPlans.Update(workoutPlanItem.WorkoutPlan);
                        db.SaveChanges();
                    }
                }
            };

            dialog.ShowDialogWindow(new WorkoutLogInputViewModel(dialog, workoutDayItem));
        }
        /// <summary>
        /// Add new workout plan and days
        /// </summary>
        public void AddWorkoutPlan()
        {
            var dialog = new WorkoutPlanInputDialog();

            dialog.Closing += (s, e) =>
            {
                if (dialog.DataContext is WorkoutPlanInputViewModel vm && vm.WorkoutPlanItem.WorkoutPlan.Id > 0)
                {
                    WorkoutPlanItems.Insert(0, vm.WorkoutPlanItem);
                }
            };

            dialog.ShowDialogWindow(new WorkoutPlanInputViewModel(dialog));
        }