Пример #1
0
        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());
            }
        }
Пример #2
0
 public int SaveBeerToUserCollectionById(string userId, int beerId)
 {
     return(_beerCollectionRepository.SaveBeerToUserCollectionById(userId, beerId));
 }