public IActionResult OnPost()
        {
            string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var    user   = User.FindFirst(ClaimTypes.NameIdentifier);

            if (selectedBeerId > 0)
            {
                int savedRowId = _beerCollectionRepository.SaveBeerToUserCollectionById(userId, selectedBeerId);

                if (savedRowId > 0)
                {
                    return(RedirectToPage("/Dashboard"));
                }
                else
                {
                    ModelState.AddModelError("SaveError", "An error prevented your request from saving, try again");
                    return(Page());
                }
            }
            else
            {
                ModelState.AddModelError("SelectError", "Select a beer");
                beers = new beersService(_beerRepository).getBeersByCountryId(CountryId);
                return(Page());
            }
        }
Beispiel #2
0
        public IActionResult OnPost()
        {
            string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (selectedBeerId > 0)
            {
                return(RedirectToPage("/DoINeedResults", new { beerId = selectedBeerId }));
            }
            else
            {
                ModelState.AddModelError("SelectError", "Select a beer");
                beers = new beersService(_beerRepository).getBeersByCountryId(CountryId);
                return(Page());
            }
        }
 public void OnGet(int countryId)
 {
     service   = new beersService(_beerRepository);
     beers     = service.getBeersByCountryId(countryId);
     CountryId = countryId;
 }