Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
0
        private async Task <List <FollowedTutors> > GetFollowedTutors(string followeeId)
        {
            List <FollowedTutors> followedTutorsList = new List <FollowedTutors>();
            var followedTutors = await followService.GetAllFollowees(followeeId);

            if (followedTutors != null && followedTutors.Count > 0)
            {
                foreach (var tutor in followedTutors)
                {
                    var previousStreams       = (await storageService.GetList <Video>(SQLQueries.GetArchivedStreamsWithUsername, tutor.Username)).Count >= 3 ? (await storageService.GetList <Video>(SQLQueries.GetArchivedStreamsWithUsername, tutor.Username)).GetRange(0, 3) : (await storageService.GetList <Video>(SQLQueries.GetArchivedStreamsWithUsername, tutor.Username));
                    var latestScheduledStream = (await scheduleService.GetSchedule(tutor)).Count == 0 ? null : (await scheduleService.GetSchedule(tutor))[0];
                    var followValue           = await followService.IsFollowingFollowee(CurrentUserProfile.Id, tutor.Id);

                    followedTutorsList.Add(new FollowedTutors(tutor, previousStreams, latestScheduledStream, followValue));
                }
            }

            return(followedTutorsList);
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
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());
        }