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());
        }
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);
        }