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
        public async Task <IActionResult> OnGet(string scheduleId)
        {
            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 });

            ChatInfo = UserChannel.ArchivedVideoId != null?encryptionService.EncryptString(UserChannel.ArchivedVideoId) : encryptionService.EncryptString("DEFAULT");

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

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

            ScheduledStream = await storageService.Get <Schedule>(SQLQueries.GetScheduleWithId, new string[] { scheduleId, DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm") });

            Schedule = await scheduleService.GetSchedule(CurrentUserProfile);

            GenerateQRCode(cookieService.Url("/Chat/Live/" + CurrentUserProfile.Username));
            Host = cookieService.host;

            return(Page());
        }
示例#3
0
        public async Task <IActionResult> OnGet()
        {
            CurrentUserProfile = await cookieService.GetCurrentUser();

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

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

            return(Page());
        }
示例#4
0
        public async Task <IActionResult> OnGet(string id, string commentId)
        {
            if (!cookieService.Authenticated)
            {
                return(Redirect(cookieService.Url("/Home/SignIn/" + encryptionService.EncryptString("/Stream/Archive/" + id + "/" + commentId))));
            }

            CurrentUserProfile = await cookieService.GetCurrentUser();

            Video = await storageService.Get <Video>(SQLQueries.GetArchivedStreamsWithStreamId, id);

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

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

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

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

            OtherVideos = await storageService.GetList <Video>(SQLQueries.GetRandomArchivedStreams, new string[] { });

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

            Comments = await commentService.GetAllComments(Video.Id);

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

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

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

            if (!string.IsNullOrEmpty(commentId))
            {
                NotificationRequestComment = await storageService.Get <Comment>(SQLQueries.GetCommentWithId, commentId);
            }
            AreThereUnseenNotifications = await notificationService.AreThereUnseenNotifications(CurrentUserProfile.Username);

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

            return(Page());
        }
示例#5
0
        public async Task <IActionResult> OnGet(string searchTerm)
        {
            var tutors = await storageService.GetList <TutorSubject>(SQLQueries.GetApprovedTutorSubjects, "");

            CurrentUserProfile = await cookieService.GetCurrentUser();

            Videos = await storageService.GetList <Video>(SQLQueries.GetArchivedStreamsInDescendingOrderByViews, "");

            PopularTutors = tutors.GetRange(0, 3);
            LiveChannels  = await storageService.GetList <Channel>(SQLQueries.GetAllUserChannelsThatAreStreaming, "");

            AllTutors = new List <TutorSubject>();
            Hashtable table = new Hashtable();

            foreach (var tutor in tutors)
            {
                if (!table.Contains(tutor.Username))
                {
                    table.Add(tutor.Username, tutor);
                    AllTutors.Add(tutor);
                }
            }
            AllScheduledStreams = await storageService.GetList <Schedule>(SQLQueries.GetAllScheduledStreams, "");

            if (searchTerm != "SW")
            {
                SearchTerm = searchTerm;
                if (MiscHelperMethods.GetCorrespondingStreamColor(SearchTerm) != null)
                {
                    isFilterTerm = true;
                }
            }

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

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

            return(Page());
        }
示例#6
0
        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());
        }
示例#7
0
        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());
        }
        public async Task <IActionResult> OnGet()
        {
            if (!cookieService.Authenticated || (await cookieService.GetCurrentUser()).ProfileType != "student")
            {
                return(Redirect(cookieService.Url("/Home/SignIn/SW")));
            }

            CurrentUserProfile = await cookieService.GetCurrentUser();

            RelatedTutors  = (await storageService.GetList <Profile>(SQLQueries.GetAllTutorsNotInTheList, new string[] { CurrentUserProfile.Id })).GetRange(0, 3);
            FollowedTutors = await GetFollowedTutors(CurrentUserProfile.Id);

            Sections = profileService.GetSections(CurrentUserProfile);
            Topics   = profileService.GetTopics(CurrentUserProfile);

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

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

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

            return(Page());
        }
示例#9
0
        public async Task <IActionResult> OnGet(string student)
        {
            if (!await cookieService.ValidateUserType(student, "student")) //checks for
            {
                return(Redirect("/Profiles/Tutor/" + student));
            }

            CurrentUserProfile = await cookieService.GetCurrentUser();

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

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

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

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

            return(Page());
        }
示例#10
0
        public async Task OnGet()
        {
            // List of streams for the carousel
            List <string> streamsWithPriority = new List <string> {
                "F8U3mEscyNB_1",
                "EBRNrFsAqZZ_1",
                "E1OKuVsAi9U_1",
                "EdowSgsAqJV_1",
                "EYd2jUscrUz_1",
                "6SAvwnsAobr_1",
                "ETWYvVscngb_1",
                "F5pYLrscQ5Q_1"
            };

            // List of the IDs of the streams to hardcode in
            List <Video> videosByViews = await storageService.GetList <Video>(SQLQueries.GetArchivedStreamsInDescendingOrderByViews);

            List <Video> videos = new List <Video>();

            foreach (string streamWithPriority in streamsWithPriority) // Add hardcoded streams
            {
                int streamIndex = videosByViews.FindIndex(x => x.StreamID.Equals(streamWithPriority));
                videos.Add(videosByViews[streamIndex]);
                videosByViews.RemoveAt(streamIndex);
            }

            int toAdd = 12 - videos.Count;  // Since Count changes while the loop is running

            for (int i = 0; i < toAdd; i++) // Fill the rest in with streams in order of view count
            {
                videos.Add(videosByViews[i]);
            }

            ArchivedVideos = videos;

            Channel streamingChannel = await storageService.Get <Channel>(SQLQueries.GetAllUserChannelsThatAreStreaming);

            if (streamingChannel == null)
            {
                FeaturedChannel = await storageService.Get <Channel>(SQLQueries.GetUserChannelWithUsername, "juliamkim");

                FeaturedTutor = await storageService.Get <DataModels.Profile>(SQLQueries.GetUserWithUsername, "juliamkim");

                FeaturedArchivedVideo = await storageService.Get <Video>(SQLQueries.GetArchivedStreamsWithUsername, "juliamkim");

                FeaturedArchivedVideo.StreamSubjectIcon = MiscHelperMethods.GetCorrespondingSubjectThumbnail(FeaturedArchivedVideo.StreamSubject);
            }
            else
            {
                FeaturedChannel = streamingChannel;
                FeaturedTutor   = await storageService.Get <Profile>(SQLQueries.GetUserWithUsername, streamingChannel.Username);

                FeaturedChannel.StreamSubjectIcon = MiscHelperMethods.GetCorrespondingSubjectThumbnail(FeaturedChannel.StreamSubject);
            }

            if (cookieService.Authenticated)
            {
                CurrentUserProfile = await cookieService.GetCurrentUser();

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

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

            ChatInfo = encryptionService.EncryptString(streamingChannel != null ? streamingChannel.ArchivedVideoId : FeaturedArchivedVideo.Id);
        }