Esempio n. 1
0
 public void UpdateMeetings()
 {
     CurrentWeekMeetings = new List <List <MeetingViewModel> >();
     for (int i = 0; i < 7; i++)
     {
         try
         {
             var response = APIClient.GetRequest($"api/Meeting/GetListOfDay/?roomId={CurrentRoom.Id}&day={CurrentWeek[i].Date.ToString()}");
             if (response.Result.IsSuccessStatusCode)
             {
                 var list = APIClient.GetElement <List <MeetingViewModel> >(response);
                 //var list = mservice.GetListOfDay(CurrentRoom.Id, CurrentWeek[i].Date);
                 CurrentWeekMeetings.Add(list);
             }
             else
             {
                 throw new Exception(APIClient.GetError(response));
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     RaisePropertyChanged("CurrentWeekMeetings");
 }
Esempio n. 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var           id = (int)value;
            UserViewModel user;

            try
            {
                var response = APIClient.GetRequest("api/User/Get/" + id);
                if (response.Result.IsSuccessStatusCode)
                {
                    user = APIClient.GetElement <UserViewModel>(response);
                    if (user == null)
                    {
                        return("");
                    }
                }
                else
                {
                    throw new Exception(APIClient.GetError(response));
                }
            }
            catch (Exception ex)
            {
                return("");
            }

            return(user);
        }
Esempio n. 3
0
 public bool RestoringPassword(string email)
 {
     try
     {
         var response = APIClient.GetRequest($"api/User/RestoringPassword/?email={email}");
         if (!response.Result.IsSuccessStatusCode)
         {
             throw new Exception(APIClient.GetError(response));
         }
         var user = APIClient.GetElement <UserViewModel>(response);
         if (user == null)
         {
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 4
0
        public void UpdateRooms()
        {
            try
            {
                var roomResponse = APIClient.GetRequest("api/Room/GetList");

                if (roomResponse.Result.IsSuccessStatusCode)
                {
                    var listRooms = APIClient.GetElement <List <RoomViewModel> >(roomResponse);
                    Rooms = listRooms;
                }
                else
                {
                    throw new Exception(APIClient.GetError(roomResponse));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            RaisePropertyChanged("Rooms");
        }
Esempio n. 5
0
        public void UpdateUsers()
        {
            try
            {
                var userResponse = APIClient.GetRequest("api/User/GetList");

                if (userResponse.Result.IsSuccessStatusCode)
                {
                    var listUsers = APIClient.GetElement <List <UserViewModel> >(userResponse);
                    Users = listUsers;
                }
                else
                {
                    throw new Exception(APIClient.GetError(userResponse));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            RaisePropertyChanged("Users");
        }
Esempio n. 6
0
 public bool SignIn(string login, string password)
 {
     try
     {
         var response = APIClient.GetRequest($"api/User/SignIn/?login={login}&password={password}");
         if (!response.Result.IsSuccessStatusCode)
         {
             throw new Exception(APIClient.GetError(response));
         }
         var user = APIClient.GetElement <UserViewModel>(response);
         if (user == null)
         {
             return(false);
         }
         CurrentUser = user;
         return(true);
     }
     catch (Exception ex)
     {
         JObject message = (JObject)JsonConvert.DeserializeObject(ex.Message);
         throw new Exception(message["ExceptionMessage"].Value <string>());
     }
 }
Esempio n. 7
0
        public ProfileWindow(DataSamples data)
        {
            InitializeComponent();
            Data                   = data;
            FIOTextBox.Text        = Data.CurrentUser.UserFIO;
            CurrentFIO             = Data.CurrentUser.UserFIO;
            FIOTextBox.Focusable   = false;
            FIOTextBox.IsEnabled   = false;
            LoginTextBox.Text      = Data.CurrentUser.UserLogin;
            CurrentLogin           = Data.CurrentUser.UserLogin;
            LoginTextBox.Focusable = false;
            LoginTextBox.IsEnabled = false;
            EmailTextBox.Text      = Data.CurrentUser.UserMail;
            CurrentEmail           = Data.CurrentUser.UserMail;
            Password               = Data.CurrentUser.UserPassword;
            EmailTextBox.Focusable = false;
            EmailTextBox.IsEnabled = false;

            PasswordTextBox.Focusable        = false;
            PasswordTextBox.IsEnabled        = false;
            PasswordConfirmTextBox.IsEnabled = false;
            PasswordConfirmTextBox.Focusable = false;


            try
            {
                var response = APIClient.GetRequest("api/Meeting/GetListUserCreatedMeetings/" + Data.CurrentUser.Id);
                if (response.Result.IsSuccessStatusCode)
                {
                    var list = APIClient.GetElement <List <MeetingViewModel> >(response);
                    if (list != null)
                    {
                        Data.UserMeetings = list;
                    }
                }
                else
                {
                    throw new Exception(APIClient.GetError(response));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            MeetingsListBoxCreated.ItemsSource = Data.UserMeetings;


            try
            {
                var response = APIClient.GetRequest("api/Meeting/GetListUserInvites/" + Data.CurrentUser.Id);
                if (response.Result.IsSuccessStatusCode)
                {
                    var list = APIClient.GetElement <List <MeetingViewModel> >(response);
                    if (list != null)
                    {
                        Data.UserMeetings = list;
                    }
                }
                else
                {
                    throw new Exception(APIClient.GetError(response));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            MeetingsListBoxInvited.ItemsSource = Data.UserMeetings;
        }