コード例 #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());
        }
コード例 #2
0
ファイル: Live.cshtml.cs プロジェクト: jeddyhsu/StreamWork
        public async Task <IActionResult> OnGet(string tutor)
        {
            if (!cookieService.Authenticated)
            {
                return(Redirect(cookieService.Url("/Home/SignIn/" + encryptionService.EncryptString("/Stream/Live/" + tutor))));
            }

            CurrentUserProfile = await cookieService.GetCurrentUser();

            UserProfile = await storageService.Get <DataModels.Profile>(SQLQueries.GetUserWithUsername, tutor);

            UserChannel = await storageService.Get <Channel>(SQLQueries.GetUserChannelWithUsername, tutor);

            if (UserChannel.StreamTitle == null)
            {
                return(Redirect(cookieService.Url("/Profiles/Tutor/" + UserProfile.Username)));
            }

            UserChannel.StreamSubjectIcon = MiscHelperMethods.GetCorrespondingSubjectThumbnail(UserChannel.StreamSubject);
            ChatInfo    = encryptionService.EncryptString(UserChannel.ArchivedVideoId);
            FollowValue = await followService.IsFollowingFollowee(CurrentUserProfile.Id, UserProfile.Id);

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

            RelatedTutors = (await storageService.GetList <DataModels.Profile>(SQLQueries.GetAllTutorsNotInTheList, new string[] { UserProfile.Id })).GetRange(0, 5);
            Sections      = profileService.GetSections(UserProfile);
            Schedule      = await scheduleService.GetSchedule(UserProfile);

            NumberOfStreams   = UserArchivedStreams.Count;
            NumberOfFollowers = await followService.GetNumberOfFollowers(UserProfile.Id);

            NumberOfViews = UserArchivedStreams.Sum(x => x.Views);

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

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

            UserChannel.Views += 1;
            await storageService.Save(UserChannel.Id, UserChannel);

            return(Page());
        }
コード例 #3
0
ファイル: Tutor.cshtml.cs プロジェクト: jeddyhsu/StreamWork
        public async Task <IActionResult> OnGet(string tutor)
        {
            if (!await cookieService.ValidateUserType(tutor, "tutor")) //checks for
            {
                return(Redirect("/Profiles/Student/" + tutor));
            }

            CurrentUserProfile = await cookieService.GetCurrentUser();

            UserProfile = await storageService.Get <Profile>(SQLQueries.GetUserWithUsername, tutor);

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

            LatestStream = await storageService.Get <Video>(SQLQueries.GetLatestArchivedStreamByUser, new string[] { UserProfile.Username });

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

            RelatedTutors = (await storageService.GetList <Profile>(SQLQueries.GetAllTutorsNotInTheList, new string[] { UserProfile.Id })).GetRange(0, 5);
            Sections      = profileService.GetSections(UserProfile);
            Topics        = profileService.GetTopics(UserProfile);
            Schedule      = await scheduleService.GetSchedule(UserProfile);

            NumberOfStreams   = UserArchivedStreams.Count;
            NumberOfViews     = UserArchivedStreams.Sum(x => x.Views);
            NumberOfFollowers = await followService.GetNumberOfFollowers(UserProfile.Id);

            if (CurrentUserProfile != null)
            {
                Notifications = await notificationService.GetNotifications(CurrentUserProfile.Username);

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

                FollowValue = await followService.IsFollowingFollowee(CurrentUserProfile.Id, UserProfile.Id);
            }

            return(Page());
        }