예제 #1
0
        public async Task <bool> Unfavorite([FromBody] FavPayload payload)
        {
            if (payload == null)
            {
                return(false);
            }
            string email = User.FindFirst(ClaimTypes.Email).Value;

            return(await _userService.RemoveFavorite(email, payload.packageId));
        }
예제 #2
0
        public async Task <bool> IsFavorite([FromBody] FavPayload payload)
        {
            return(await Task.Run(() =>
            {
                string email = User.FindFirst(ClaimTypes.Email).Value;
                string[] favorites = _userService.GetFavorites(email);

                foreach (string s in favorites)
                {
                    if (s == payload.packageId)
                    {
                        return true;
                    }
                }

                return false;
            }));
        }