Example #1
0
        private async void GetSchedulesFromServer()
        {
            var schedules = await _dataTransport.GetRequestAsync <List <ScheduleClass> >(Urls.Schedules, true);

            Schedules     = MakeFullWeeks(schedules);
            SKUDSchedules = new ObservableCollection <ScheduleClass>(Schedules.Where(s => s.Type == ScheduleTypes.SKUD));
            SKUDSchedules.Insert(0, new ScheduleClass(true));
            VentilationSchedules = new ObservableCollection <ScheduleClass>(Schedules.Where(s => s.Type == ScheduleTypes.Ventilation));
            VentilationSchedules.Insert(0, new ScheduleClass(true));
            LightSchedules = new ObservableCollection <ScheduleClass>(Schedules.Where(s => s.Type == ScheduleTypes.Light));
            LightSchedules.Insert(0, new ScheduleClass(true));
            HeatSchedules = new ObservableCollection <ScheduleClass>(Schedules.Where(s => s.Type == ScheduleTypes.Heat));
            HeatSchedules.Insert(0, new ScheduleClass(true));
            ACSchedules = new ObservableCollection <ScheduleClass>(Schedules.Where(s => s.Type == ScheduleTypes.AC));
            ACSchedules.Insert(0, new ScheduleClass(true));

            OnDataReceivedEvent();
        }
Example #2
0
        private async void LoginRequest(string requestString)
        {
            Status = string.Empty;
            try
            {
                var apiKey = await _dataTransport.GetRequestAsync <string>(requestString, false);

                if (!string.IsNullOrWhiteSpace(apiKey))
                {
                    Guid key;
                    if (Guid.TryParse(apiKey, out key))
                    {
                        _esterBootstrapper.BeginLoad(key);
                    }
                    else
                    {
                        Status = "Ошибка. Неверный ApiKey";
                    }
                }
                else
                {
                    IsViewEnabled = true;
                    Status        = "Произошла ошибка на сервере. Попробуйте позднее или обратитесь к администратору.";
                }
            }
            catch (BadRequestException)
            {
                IsViewEnabled = true;
                Status        = "Неверный логин или пароль";
            }
            catch (Exception)
            {
                IsViewEnabled = true;
                Status        = "Не удалось установить связь с сервером. Попробуйте позднее или обратитесь к администратору.";
            }
        }