Esempio n. 1
0
        public async Task <IActionResult> OnGetAsync()
        {
            Employee = await userManager.GetUserAsync(User).ConfigureAwait(false);

            Role = await roleManager.FindByIdAsync(Employee.RoleId.ToString()).ConfigureAwait(false);

            if (!Role.CanAdministerSystem)
            {
                return(RedirectToPage("/Index"));
            }

            var voteResults = (await reviews.FetchAggregatedVenueVotes().ConfigureAwait(false))
                              .Ensure(e => e.HasValue, "Votes found")
                              .OnSuccess(e => e.Value)
                              .OnBoth(e => e.IsSuccess ? e.Value : new List <AggregatedVenueVote>());

            var results = (await reviews.FetchCountedReviews(PageNumber, 20).ConfigureAwait(false))
                          .Ensure(e => e.HasValue, "Reviews found")
                          .OnSuccess(e => e.Value)
                          .OnBoth(e => e.IsSuccess ? e.Value : new PaginatedResult <Review> {
                Data = new List <Review>(), Count = 0
            });

            TotalResults = results.Count;
            Reviews      = results.Data;
            Votes        = voteResults;
            Title        = $"Reviews ({TotalResults})";
            HasNextPage  = (PageNumber + 1) <= (TotalResults / 20);

            return(Page());
        }