示例#1
0
        public async Task <ActionResult> OnGet()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToPage("/Account/Login", new { area = "Identity" }));
            }
            try
            {
                int?UserGroupID = HttpContext.Session.GetInt32("UserGroupID");
                var user        = await _userManager.GetUserAsync(User);

                PotAccess = await _siteData.GetPotAccess(user.Id.ToString(), UserGroupID);

                int index = PotAccess.FindIndex(item => item.PotID == 4);
                if (index == -1)
                {
                    return(RedirectToPage("/Account/AccessDenied", new { area = "Identity" }));
                }
                Coffees = _coffeeData.GetCoffeeList(UserGroupID).Result;
                var users = _siteData.GetUserList(UserGroupID, 4);
                users.Result.ForEach(x =>
                {
                    Users.Add(x);
                });

                foreach (var item in Coffees)
                {
                    var crl = _coffeeData.GetCoffeeRatings(item.CoffeeID).Result;
                    foreach (var rating in crl)
                    {
                        CoffeeRatings cr = new CoffeeRatings();
                        cr = rating;
                        CoffeeRatingsList.Add(cr);
                    }
                }
                return(Page());
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                throw new Exception(ex.ToString());
            }
        }