Ejemplo n.º 1
0
        public async Task GetMyProcessedVideosTest()
        {
            var authorizedHttpClient = await base.SignIn(Role.User);

            VideoClientService videoClientService = base.CreateVideoClientService();
            var dbContext = TestsBase.CreateDbContext();
            var videos    = await dbContext.VideoInfo.ToListAsync();

            var userEntity = await dbContext.ApplicationUser.Where(p => p.AzureAdB2cobjectId.ToString() ==
                                                                   TestsBase.TestAzureAdB2CAuthConfiguration !.AzureAdUserObjectId).SingleAsync();

            var testVideoEntity = CreateTestVideoEntity();

            testVideoEntity.ApplicationUserId = userEntity.ApplicationUserId;
            await dbContext.VideoInfo.AddAsync(testVideoEntity);

            await dbContext.SaveChangesAsync();

            var result = await videoClientService.GetMyProcessedVideosAsync();

            Assert.AreEqual(1, result !.Length, "Invalid count of owned videos for test user");
        }
Ejemplo n.º 2
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;
            }
        }