public async Task TrackAuthenticatedVisitAsync(VisitorTrackingModel visitorTrackingModel,
                                                       bool createNewSession)
        {
            if (createNewSession)
            {
                SessionId = Guid.NewGuid();
            }
            visitorTrackingModel.SessionId = SessionId;
            var authorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
            var response             = await authorizedHttpClient.PostAsJsonAsync(ApiRoutes.VisitorTrackingController.TrackAuthenticatedClientInformation, visitorTrackingModel);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
            else
            {
                visitorTrackingModel = await response.Content.ReadFromJsonAsync <VisitorTrackingModel>();

                this.VisitorTrackingId = visitorTrackingModel.VisitorTrackingId;
            }
        }
示例#2
0
        private async Task DeleteSelectedImage()
        {
            try
            {
                this.IsLoading = true;
                StateHasChanged();
                string requestUrl = $"api/Image/DeleteImage?imageName={this.SelectedImageModel.ImageName}";
                var    response   = await this.AuthorizedHttpClient.DeleteAsync(requestUrl);

                if (response.IsSuccessStatusCode)
                {
                    await this.ToastifyService.DisplaySuccessNotification("Image has been deleted");
                }
                else
                {
                    ProblemHttpResponse problemHttpResponse = await response.Content.ReadFromJsonAsync <ProblemHttpResponse>();

                    await this.ToastifyService.DisplayErrorNotification(problemHttpResponse.Detail);
                }
            }
            catch (Exception ex)
            {
                await this.ToastifyService.DisplayErrorNotification(ex.Message);
            }
            finally
            {
                this.IsLoading          = false;
                this.SelectedImageModel = null;
                this.HideConfirmDeleteDialog();
                await this.LoadImages();

                StateHasChanged();
            }
        }
        public async Task AddVideoJobAsync(VideoJobModel videoJobModel)
        {
            var authorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
            var response             = await authorizedHttpClient.PostAsJsonAsync(ApiRoutes.VideoJobController.AddVideoJob, videoJobModel);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
        public async Task AddFundsAsync(string paypalOrderId)
        {
            var    authorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
            string requestUrl           = $"{Constants.ApiRoutes.UserProfileController.AddFunds}?orderId={paypalOrderId}";
            var    response             = await authorizedHttpClient.PostAsync(requestUrl, null);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
        public async Task SaveMonetizationAsync(GlobalMonetizationModel globalMonetizationModel)
        {
            var authorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
            var response             = await authorizedHttpClient.PostAsJsonAsync(ApiRoutes.UserProfileController.SaveMonetization,
                                                                                  globalMonetizationModel);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
        public async Task DeleteVideoPlaylistAsync(long videoPlaylistId)
        {
            var authorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
            var response             = await authorizedHttpClient.DeleteAsync(
                $"{ApiRoutes.VideoPlaylistController.DeleteVideoPlaylist}?videoPlaylistId={videoPlaylistId}");

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
        public async Task AddAnonymousUserRequestAsync(CreateUserRequestModel createUserRequestModel)
        {
            var anonymousHttpClient = this.HttpClientService.CreateAnonymousClient();
            var response            = await anonymousHttpClient.PostAsJsonAsync(
                ApiRoutes.UserRequestController.AddAnonymousUserRequest, createUserRequestModel);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
示例#8
0
        public async Task InviteUserAsync(InviteUserModel inviteUserModel)
        {
            var authorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
            var response             = await authorizedHttpClient.PostAsJsonAsync <InviteUserModel>(
                Constants.ApiRoutes.UserController.InviteUser, inviteUserModel);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
        public async Task UpdateMyVideoAsync(string videoId, UpdateVideoModel updateVideoModel)
        {
            var authorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
            var response             = await authorizedHttpClient.PutAsJsonAsync($"{ApiRoutes.VideoController.UpdateMyVideo}" +
                                                                                 $"?videoId={videoId}", updateVideoModel);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
        public async Task TrackAnonymousVisitAsync(VisitorTrackingModel visitorTrackingModel,
                                                   bool createNewSession)
        {
            if (createNewSession)
            {
                SessionId = Guid.NewGuid();
            }
            visitorTrackingModel.SessionId = SessionId;
            var anonymousHttpClient = this.HttpClientService.CreateAnonymousClient();
            var response            = await anonymousHttpClient.PostAsJsonAsync(ApiRoutes.VisitorTrackingController.TrackAnonymousClientInformation, visitorTrackingModel);

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

                    if (problemHttpResponse != null)
                    {
                        throw new CustomValidationException(problemHttpResponse.Detail);
                    }
                    else
                    {
                        throw new CustomValidationException(response.ReasonPhrase);
                    }
                }
                catch (Exception)
                {
                    string errorText = await response.Content.ReadAsStringAsync();

                    string reasonPhrase = response.ReasonPhrase;
                    throw new CustomValidationException($"{reasonPhrase} - {errorText}");
                }
            }
            else
            {
                visitorTrackingModel = await response.Content.ReadFromJsonAsync <VisitorTrackingModel>();

                this.VisitorTrackingId = visitorTrackingModel.VisitorTrackingId;
            }
        }
        public async Task ApproveVideoJobApplicationAsync(long videoJobApplicationId)
        {
            var authoriedHttpClient = this.HttpClientService.CreateAuthorizedClient();
            var response            = await authoriedHttpClient.PostAsync(
                $"{Common.Global.Constants.ApiRoutes.VideoJobApplicationController.ApproveVideoJobApplication}" +
                $"?videoJobApplicationId={videoJobApplicationId}", null);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
示例#12
0
        public async Task AddUserFollowerAsync(long followedApplicationUserId)
        {
            var authorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();
            var response             = await authorizedHttpClient
                                       .PostAsync($"{Constants.ApiRoutes.UserController.AddUserFollower}" +
                                                  $"?followedApplicationUserId={followedApplicationUserId}", null);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
        public async Task UploadVideoAsync(UploadVideoModel uploadVideoModel)
        {
            var authorizedHttpClient = this.HttpClientService.CreateAuthorizedClient();

            authorizedHttpClient.Timeout = TimeSpan.FromMinutes(15);
            var response = await authorizedHttpClient.PostAsJsonAsync(ApiRoutes.VideoController.UploadVideo, uploadVideoModel);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
        public async Task UpdateVisitTimeElapsedAsync()
        {
            var anonymousHttpClient = HttpClientService.CreateAnonymousClient();
            var response            = await anonymousHttpClient.PutAsync(
                $"{ApiRoutes.VisitorTrackingController.UpdateVisitTimeElapsed}" +
                $"?visitorTrackingId={this.VisitorTrackingId}", null);

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

                if (problemHttpResponse != null)
                {
                    throw new CustomValidationException(problemHttpResponse.Detail);
                }
                else
                {
                    throw new CustomValidationException(response.ReasonPhrase);
                }
            }
        }
示例#15
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();
            }
        }