private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     //Stop the loading  RUNS when thread is COMPLETED can work on UI
     BtnCreateUser.Content  = "Register";
     BtnLoginUser.IsEnabled = true;
     LoadSpinner.Visibility = Visibility.Hidden;
     LoadSpinner.Stop();
     LoadSpinner.Close();
     if (loginUser != null)
     {
         if (loginUser.IsAdmin)
         {
             Window WindowAdminMenu = new AdminWindow(loginUser);
             WindowAdminMenu.Show();
             Close();
         }
         else if (loginUser.IsCustomer)
         {
             Window WindowCustomerMenu = new CustomerScreen(loginUser);
             WindowCustomerMenu.Show();
             Close();
         }
         else
         {
             lblInvalidText.Content = "Invalid Account Information";
         }
     }
     else
     {
         lblInvalidText.Visibility = Visibility.Visible;
     }
 }
        async Task OnSubmitHandle()
        {
            LoadSpinner.Show();
            try
            {
                if (BookModel.CategoryId == null || BookModel.CategoryId.Contains("..."))
                {
                    throw new Exception("Виберіть категорію!");
                }
                BookModel.Year       = Year.ToString();
                BookModel.Image      = null;
                BookModel.DateCreate = DateTime.Now;
                BookModel.IsEbook    = IsEBook;

                await authService.RefreshToken();

                var result = await LibraryService.CreateBookAsync(BookModel);

                await LibraryService.UploadBookImage(result.Id, new ImageApiModel { Photo = ImageBase64 });
                await FileUpload(result.Id);

                Toast.ShowSuccess("Книга успішно додана!");
                NavigationManager.NavigateTo(QueryHelpers.AddQueryString("/book", "bookId", result.Id));
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                Toast.ShowError(ex.Message);
                Console.WriteLine("Error Message: " + ErrorMessage);
            }
            finally
            {
                LoadSpinner.Hide();
            }
        }
Example #3
0
        async void OnSubmitHandle()
        {
            LoadSpinner.Show();
            try
            {
                var message = new CallOwnerApiModel();
                message.Subject = Subject;
                message.Text    = Text;
                message.BookId  = BookItem.Id;
                await AuthService.RefreshToken();

                await HttpService.Post <CallOwnerApiModel, MessageApiModel>(ApiUrls.CallToOwner, message);

                Toast.ShowSuccess("Повідомлення успішно відправлено!");
                NavigationManager.NavigateTo("/index");
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                Toast.ShowError("Помилка. Повідомлення не відправлено!");
                Console.WriteLine("Error Message: " + ErrorMessage);
            }
            finally
            {
                LoadSpinner.Hide();
            }
        }
        async Task ImageFileSelected()
        {
            LoadSpinner.Show();
            IsImageSelected = true;
            foreach (var file in await FileReaderService.CreateReference(InputElementImage).EnumerateFilesAsync())
            {
                using (MemoryStream memoryStream = await file.CreateMemoryStreamAsync(4 * 1024))
                {
                    var imageBytes = new byte[memoryStream.Length];
                    memoryStream.Read(imageBytes, 0, (int)memoryStream.Length);
                    ImageBase64   = Convert.ToBase64String(imageBytes);
                    ImageUrl      = $"data:image/jpeg;base64, {ImageBase64}";
                    IsPhotoLoaded = true;
                }
            }

            StateHasChanged();
            LoadSpinner.Hide();
        }
 private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {   //Start the .Gif (Play and make visible)    free to interact with UI in progressChanged.
     LoadSpinner.Play();
     LoadSpinner.Visibility = Visibility.Visible;
     try
     {
         loginUser = SQLuserAccess.UserLogin(username, password);
         if (loginUser != null)
         {
             if (username == loginUser.Username && password == loginUser.Password)
             {
             }
             else
             {
                 lblInvalidText.Visibility = Visibility.Visible;
             }
         }
         else
         {
             lblInvalidText.Visibility = Visibility.Visible;
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }
 }
 private void LoadSpinner_MediaEnded(object sender, RoutedEventArgs e)
 {
     LoadSpinner.Position = new TimeSpan(0, 0, 1);
     LoadSpinner.Play();
 }