Beispiel #1
0
        public async Task <ActionResult <IEnumerable <ShopViewModel> > > Get()
        {
            var currentUser = await _userManager.GetUserAsync(_httpContextAccessor.HttpContext.User);

            var favoriteShops = await _favoriteRepository.GetFavoriteAsync(currentUser);

            if (favoriteShops == null || favoriteShops.Count() == 0)
            {
                return(NoContent());
            }

            var viewModels = favoriteShops.Select(shop => new ShopViewModel
            {
                Id        = shop.Id,
                Name      = shop.Name,
                latitude  = shop.Location.Y,
                longitude = shop.Location.X
            });

            return(Ok(viewModels));
        }