Пример #1
0
        private async void SaveSelectedPlans(object param)
        {
            string msg = "Сохраненныё графики будут очищены", title = "Вы уверены?", butOk = "Да", butCancel = "Нет";
            var    res = await Application.Current.MainPage.DisplayAlert(title, msg, butOk, butCancel);

            if (!res)
            {
                return;
            }

            var Plans = new List <Plan>();

            if (StartDate > EndDate)
            {
                await Application.Current.MainPage.DisplayAlert("Ошибка ввода", "Начальная дата не может быть больше конечной", "Ок");

                return;
            }

            List <PlanTypes> filter = new List <PlanTypes>();

            if (WorkDaysSelected)
            {
                filter.Add(PlanTypes.Working);
            }
            if (DaysOffSelected)
            {
                filter.Add(PlanTypes.DayOff);
            }
            if (HolidayDaysSelected)
            {
                filter.Add(PlanTypes.Holiday);
            }
            if (HospitalDaysSelected)
            {
                filter.Add(PlanTypes.Hospital);
            }

            try
            {
                Plans = await Client.GetPlans(StartDate, EndDate, filter.ToArray());

                foreach (var plan in Plans)
                {
                    plan.StartDay = ToShorter(plan.StartDay);
                    plan.EndDay   = ToShorter(plan.EndDay);
                    plan.TypePlan = Globals.PlanTypes[plan.TypePlan];
                }
                await PlanLoader.SetPlans(Plans);

                await Application.Current.MainPage.DisplayAlert("Все готово!", "Планы сохранены в памяти", "Ок");
            }
            catch (Exception exc)
            {
                await FatalError(exc.Message);

                return;
            }
        }