Ejemplo n.º 1
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                IsLoading = true;
                this.AllMyConversationsUsers =
                    await this.UserMessageClientService.GetMyConversationsUsersAsync();

                if (this.AllMyConversationsUsers.Length > 0)
                {
                    this.SelectedUser = this.AllMyConversationsUsers[0];
                    this.AllMyConversationsWithSelectedUser = await
                                                              this.UserMessageClientService
                                                              .GetMyConversationsWithUserAsync(this.SelectedUser.ApplicationUserId);

                    this.MessageToSend.ToApplicationUserId = this.SelectedUser.ApplicationUserId;
                }
            }
            catch (Exception ex)
            {
                ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }
Ejemplo n.º 2
0
        private async Task OnValidSubmitAsync()
        {
            try
            {
                IsLoading = true;
                string requestUrl = IsEdit ? "api/Product/EditProduct" : "api/Product/AddProduct";
                var    response   = await this.AuthorizedHttpClient
                                    .PostAsJsonAsync <ProductModel>(requestUrl, this.ProductModel);

                if (!response.IsSuccessStatusCode)
                {
                    var problemHttpResponse = await response.Content.ReadFromJsonAsync <ProblemHttpResponse>();

                    await this.ToastifyService.DisplayErrorNotification(problemHttpResponse.Detail);
                }
                else
                {
                    string actionMessage = IsEdit ? "edited" : "created";
                    await ToastifyService.DisplaySuccessNotification($"Product '{this.ProductModel.Name}' " +
                                                                     $"has been {actionMessage}");

                    NavigationManager.NavigateTo(Constants.AdminPagesRoutes.ListProducts);
                }
            }
            catch (Exception ex)
            {
                await ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }
Ejemplo n.º 3
0
        private async Task ApplyToVideoJob()
        {
            if (this.VideoJobApplicationEditForm.EditContext.Validate())
            {
                try
                {
                    IsLoading = true;
                    await this.VideoJobApplicationClientService
                    .AddVideoJobApplicationAsync(this.CreateVideoJobApplicationModel);

                    CleanVideoJobApplication();
                    await LoadJobs();

                    ToastifyService.DisplaySuccessNotification(Localizer[VideoJobApplicationSentTextKey]);
                }
                catch (Exception ex)
                {
                    CleanVideoJobApplication();
                    ToastifyService.DisplayErrorNotification(ex.Message);
                }
                finally
                {
                    IsLoading = false;
                }
            }
        }
Ejemplo n.º 4
0
        private async Task OnValidSubmit()
        {
            try
            {
                this.IsLoading = true;
                var response = await this.AuthorizedHttpClient.PostAsJsonAsync <ImageUploadModel>("api/Image/UploadImage",
                                                                                                  this.ImageUploadModel);

                if (!response.IsSuccessStatusCode)
                {
                    var problemHttpResponse = await response.Content.ReadFromJsonAsync <ProblemHttpResponse>();

                    this.ErrorMessage = problemHttpResponse.Detail;
                }
                else
                {
                    this.ImageUploadModel = new ImageUploadModel();
                    await ToastifyService.DisplaySuccessNotification("Image has been uploaded");

                    this.NavigationManager.NavigateTo(Constants.AdminPagesRoutes.ListImages);
                }
            }
            catch (Exception ex)
            {
                this.ErrorMessage = ex.Message;
            }
            finally
            {
                if (!String.IsNullOrWhiteSpace(this.ErrorMessage))
                {
                    await ToastifyService.DisplayErrorNotification(this.ErrorMessage);
                }
                this.IsLoading = false;
            }
        }
Ejemplo n.º 5
0
        private async Task OnValidSubmit()
        {
            try
            {
                this.IsLoading = true;
                var response = await AuthorizedHttpClient.PostAsJsonAsync("api/Promotion/AddPromotion", this.PromotionModel);

                if (!response.IsSuccessStatusCode)
                {
                    var problemHttpResponse = await response.Content.ReadFromJsonAsync <ProblemHttpResponse>();

                    await this.ToastifyService.DisplayErrorNotification(problemHttpResponse.Detail);
                }
                else
                {
                    await this.ToastifyService.DisplaySuccessNotification("Promotion has been added");

                    NavigationManager.NavigateTo("Admin/Promos/List");
                }
            }
            catch (Exception ex)
            {
                await ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                this.IsLoading = false;
            }
        }
Ejemplo n.º 6
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                this.CultureModels = await this.LocalizationClientService.GetSupportedCulturesAsync();

                this.SupportedCultures = CultureModels.Select(p => CultureInfo.GetCultureInfo(p.Name)).ToArray();
            }
            catch (Exception ex)
            {
                ToastifyService.DisplayErrorNotification(ex.Message);
            }
        }
Ejemplo n.º 7
0
        public async void OnApprove(PaypalCheckoutApprovedDataModel data,
                                    PaypalCheckoutApprovedDetailsModel details)
        {
            try
            {
                await this.UserProfileClientService.AddFundsAsync(data.orderID);

                ToastifyService.DisplaySuccessNotification($"Fundas have been added to your {Common.Global.Constants.Titles.AppTitle} Wallter");
                await OnFundsAdded.InvokeAsync();
            }
            catch (Exception ex)
            {
                ToastifyService.DisplayErrorNotification(ex.Message);
            }
        }
Ejemplo n.º 8
0
 protected async override Task OnInitializedAsync()
 {
     try
     {
         IsLoading        = true;
         this.AllKeywords = await this.VideoClientService.ListAllKeywordsAsync();
     }
     catch (Exception ex)
     {
         ToastifyService.DisplayErrorNotification(ex.Message);
     }
     finally
     {
         IsLoading = false;
     }
 }
Ejemplo n.º 9
0
        private async Task OnApplyToVideoJobClickedAsync(VideoJobModel videoJobModel)
        {
            var state = await AuthenticationStateTask;

            if (state != null && state.User.Identity.IsAuthenticated)
            {
                this.SelectdVideoJob = videoJobModel;
                this.CreateVideoJobApplicationModel.VideoJobId = videoJobModel.VideoJobId;
                this.ShowApplyToVideoJobModal = true;
            }
            else
            {
                ToastifyService.DisplayWarningNotification(Localizer[MustBeLoggedInTextKey],
                                                           Localizer[AccessDeniedTextKey]);
            }
        }
Ejemplo n.º 10
0
 protected override async Task OnInitializedAsync()
 {
     try
     {
         IsLoading           = true;
         this.VideoInfoModel = await this.VideoClientService.GetVideoAsync(this.VideoId);
     }
     catch (Exception ex)
     {
         ToastifyService.DisplayErrorNotification(ex.Message);
     }
     finally
     {
         IsLoading = false;
     }
 }
Ejemplo n.º 11
0
 protected async override Task OnInitializedAsync()
 {
     this.AuthorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
     try
     {
         string requestUrl = "api/Configuration/GetErrorLogPowerBIUrl";
         this.ReportUrl = await this.AuthorizedHttpClient.GetStringAsync(requestUrl);
     }
     catch (Exception ex)
     {
         await ToastifyService.DisplayErrorNotification(ex.Message);
     }
     finally
     {
     }
 }
Ejemplo n.º 12
0
 protected async override Task OnInitializedAsync()
 {
     try
     {
         this.IsLoading           = true;
         this.AnonymousHttpClient = this.HttpClientService.CreateAnonymousClient();
         this.AllPromotions       = await AnonymousHttpClient.GetFromJsonAsync <PromotionModel[]>("api/Promotion/ListPromotions");
     }
     catch (Exception ex)
     {
         await ToastifyService.DisplayErrorNotification(ex.Message);
     }
     finally
     {
         IsLoading = false;
     }
 }
Ejemplo n.º 13
0
 private async Task LoadImages()
 {
     try
     {
         this.IsLoading            = true;
         this.AuthorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
         this.AllImages            = await this.AuthorizedHttpClient.GetFromJsonAsync <ImageModel[]>("api/Image/ListImages");
     }
     catch (Exception ex)
     {
         await ToastifyService.DisplayErrorNotification(ex.Message);
     }
     finally
     {
         this.IsLoading = false;
     }
 }
Ejemplo n.º 14
0
 protected async override Task OnInitializedAsync()
 {
     try
     {
         IsLoading = true;
         this.AuthorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
         await LoadProducts();
     }
     catch (Exception ex)
     {
         await ToastifyService.DisplayErrorNotification(ex.Message);
     }
     finally
     {
         IsLoading = false;
     }
 }
Ejemplo n.º 15
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                this.UserYouTubeChannels = await this.UserYouTubeChannelClientService
                                           .GetUserYouTubeChannelsAsync(UserId);

                if (this.UserYouTubeChannels?.Length > 0)
                {
                    this.SelectedChannelId = this.UserYouTubeChannels[0].YouTubeChannelId;
                    await LoadSelectedChannelVideos();
                }
            }
            catch (Exception ex)
            {
                ToastifyService.DisplayErrorNotification(ex.Message);
            }
        }
Ejemplo n.º 16
0
 protected async override Task OnInitializedAsync()
 {
     try
     {
         IsLoading = true;
         this.AuthorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
         string requestUrl = "api/Error/ListErrors";
         this.AllErrors = await this.AuthorizedHttpClient.GetFromJsonAsync <ErrorLogModel[]>(requestUrl);
     }
     catch (Exception ex)
     {
         await ToastifyService.DisplayErrorNotification(ex.Message);
     }
     finally
     {
         IsLoading = false;
     }
 }
Ejemplo n.º 17
0
        private async Task OnValidSubmit()
        {
            try
            {
                IsSubmitting = true;
                await this.VideoClientService.UpdateMyVideoAsync(this.VideoInfoModel.VideoId, this.UpdateVideoModel);

                this.ToastifyService.DisplaySuccessNotification("Video has been updated");
            }
            catch (Exception ex)
            {
                ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                IsSubmitting = false;
                StateHasChanged();
            }
        }
Ejemplo n.º 18
0
        protected async override Task OnInitializedAsync()
        {
            try
            {
                IsLoading = true;
                this.AuthorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
                this.AzureMapsKey         = await this.AuthorizedHttpClient.GetStringAsync("api/Configuration/GetAzureMapsKey");

                this.CanRenderMap = true;
                this.AllProducts  = await this.AuthorizedHttpClient
                                    .GetFromJsonAsync <ProductModel[]>("api/Product/ListProducts");
            }
            catch (Exception ex)
            {
                await ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }
Ejemplo n.º 19
0
        private async Task SendMessageAsync()
        {
            try
            {
                IsLoading = true;

                this.MessageToSend.ToApplicationUserId = this.SelectedUser.ApplicationUserId;
                await this.UserClientService.SendMessageAsync(this.MessageToSend);
                await LoadMyConversationsWithSelectedUser();

                this.MessageToSend.Message = String.Empty;
            }
            catch (Exception ex)
            {
                ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }
Ejemplo n.º 20
0
 protected override async Task OnInitializedAsync()
 {
     if (!FeatureClientService.IsFeatureEnabled(Common.Global.Enums.FeatureType.VideoJobSystem))
     {
         NavigationManager.NavigateTo("/");
         return;
     }
     try
     {
         IsLoading = true;
         await LoadJobs();
     }
     catch (Exception ex)
     {
         ToastifyService.DisplayErrorNotification(ex.Message);
     }
     finally
     {
         IsLoading = false;
     }
 }
        private async Task OnReceivedApplicationSelected(VideoJobApplicationModel videoJobApplicationModel)
        {
            try
            {
                IsLoading = true;
                await this.VideoJobApplicationClientService
                .ApproveVideoJobApplicationAsync(videoJobApplicationModel.VideoJobApplicationId);

                this.VideoJobApplications = await this.VideoJobApplicationClientService
                                            .GetNewReceivedVideoJobApplicationsAsync();

                ToastifyService.DisplaySuccessNotification(Localizer[ApplicationApprovedTextKey]);
            }
            catch (Exception ex)
            {
                ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }
Ejemplo n.º 22
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                IsLoading = true;
                ShowAvailableJobsButton      = FeatureClientService.IsFeatureEnabled(FeatureType.VideoJobSystem);
                this.NewCommentModel.VideoId = this.VideoId;
                string baseUrl        = this.NavigationManager.BaseUri;
                var    ogThumbnailurl = Constants.ApiRoutes.OpenGraphController.VideoThumbnail.Replace("{videoId}", this.VideoId);
                this.VideoThumbnailUrl = $"{baseUrl}{ogThumbnailurl}";
                this.VideoModel        = await this.VideoClientService.GetVideoAsync(VideoId);
                await LoadComments();

                if (AuthenticationStateTask is not null)
                {
                    var state = await AuthenticationStateTask;
                    if (state is not null && state.User is not null && state.User.Identity.IsAuthenticated)
                    {
                        var myVideos = await VideoClientService.GetMyProcessedVideosAsync();

                        if (myVideos.Any(p => p.VideoId == this.VideoId) &&
                            FeatureClientService.IsFeatureEnabled(FeatureType.VideoJobSystem))
                        {
                            //Logged in user is current video's owner
                            ShowAddVideoJobButton = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }
Ejemplo n.º 23
0
        private async Task DeleteSelectedPromotion()
        {
            try
            {
                StateHasChanged();
                IsLoading = true;
                string requestUrl = $"api/Promotion/DeletePromotion?promotionId={this.SelectedPromotionModel.PromotionId}";
                var    response   = await this.AuthorizedHttpClient.DeleteAsync(requestUrl);

                if (!response.IsSuccessStatusCode)
                {
                    ProblemHttpResponse problemHttpResponse =
                        await response.Content.ReadFromJsonAsync <ProblemHttpResponse>();

                    await ToastifyService.DisplayErrorNotification(problemHttpResponse.Detail);
                }
                else
                {
                    await ToastifyService.DisplaySuccessNotification("Promotions has been deleted");

                    NavigationManager.NavigateTo(Constants.AdminPagesRoutes.ListPromos);
                }
            }
            catch (Exception ex)
            {
                await ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                IsLoading = false;
                this.SelectedPromotionModel = null;
                this.HideConfirmDeleteDialog();
                await this.LoadPromotions();

                StateHasChanged();
            }
        }
Ejemplo n.º 24
0
        protected async override Task OnInitializedAsync()
        {
            var accessToken = await this.AccessTokenProvider.RequestAccessToken();

            if (accessToken.TryGetToken(out var token))
            {
                HubConnection = new HubConnectionBuilder()
                                .WithUrl(NavigationManager.ToAbsoluteUri(Common.Global.Constants.Hubs.NotificationHub),
                                         options =>
                {
                    options.AccessTokenProvider = () => Task.FromResult(token.Value);
                })
                                .Build();

                HubConnection.On <NotificationModel>(Common.Global.Constants.Hubs.ReceiveMessage, (model) =>
                {
                    ReceivedNotifications.Add(model);
                    ToastifyService.DisplayInformationNotification(model.Message);
                    StateHasChanged();
                });

                await HubConnection.StartAsync();
            }
        }