Ejemplo n.º 1
0
        public async Task <IActionResult> OnGet()
        {
            if (!cookieService.Authenticated || (await cookieService.GetCurrentUser()).ProfileType != "tutor")
            {
                return(Redirect(cookieService.Url("/Home/SignIn/SW")));
            }

            CurrentUserProfile = await cookieService.GetCurrentUser();

            UserChannel = await storageService.Get <Channel>(SQLQueries.GetUserChannelWithUsername, new string[] { CurrentUserProfile.Username });

            UserArchivedStreams = await storageService.GetList <Video>(SQLQueries.GetArchivedStreamsWithUsername, new string[] { CurrentUserProfile.Username });

            Sections = profileService.GetSections(CurrentUserProfile);
            Topics   = profileService.GetTopics(CurrentUserProfile);
            Schedule = await scheduleService.GetSchedule(CurrentUserProfile);

            Followers = await followService.GetAllFollowers(CurrentUserProfile.Id);

            Followees = await followService.GetAllFollowees(CurrentUserProfile.Id);

            NumberOfStreams   = UserArchivedStreams.Count;
            NumberOfViews     = UserArchivedStreams.Sum(x => x.Views);
            NumberOfFollowers = Followers == null ? 0 : Followers.Count;
            NumberOfFollowees = Followees == null ? 0 : Followees.Count;

            Notifications = await notificationService.GetNotifications(CurrentUserProfile.Username);

            AreThereUnseenNotifications = await notificationService.AreThereUnseenNotifications(CurrentUserProfile.Username);

            DefaultBanner         = MiscHelperMethods.defaultBanner;
            DefaultProfilePicture = MiscHelperMethods.defaultProfilePicture;

            return(Page());
        }