示例#1
0
        public async Task <IActionResult> Index()
        {
            UsedGamesAPISellerResponse response = await _usedGamesAPISellers.GetGamesAsync(_sellerLoginManager.GetUserId(), _sellerLoginManager.GetUserToken());

            if (!response.Success)
            {
                return(RedirectToAction(nameof(Error), "Home", new { area = "Seller" }));
            }

            return(View(response.Games));
        }
示例#2
0
        public async Task <UsedGamesAPISellerResponse> GetGamesAsync(int sellerId, string token)
        {
            ConfigureToken(token);
            HttpResponseMessage responseMsg = await _client.GetAsync(_client.BaseAddress + $"{sellerId}/games");

            string responseStr = await responseMsg.Content.ReadAsStringAsync();

            UsedGamesAPISellerResponse response = JsonConvert.DeserializeObject <UsedGamesAPISellerResponse>(responseStr);

            response.Success = responseMsg.IsSuccessStatusCode;
            if (responseMsg.StatusCode == HttpStatusCode.Unauthorized)
            {
                response.IsUnauthorized = true;
            }

            return(response);
        }