Пример #1
0
        public async Task <IActionResult> Login(UserLoginDTO userDTO)
        {
            UsedGamesAPILoginResponse response = await _usedGamesAPIClients.LoginAsync(userDTO);

            if (!response.Success)
            {
                ViewData["MSG_E"] = response.Message;
                return(View(userDTO));
            }

            _clientLoginManager.Login(response.User, response.Token);
            return(RedirectToAction(nameof(Index)));
        }
Пример #2
0
        public async Task <IActionResult> Login(UserLoginDTO userDTO)
        {
            UsedGamesAPILoginResponse response = await _usedGamesAPISellers.LoginAsync(userDTO);

            if (!response.Success)
            {
                ViewData["MSG_E"] = response.Message;
                return(View(userDTO));
            }

            _sellerLoginManager.Login(response.User, response.Token);
            User user = _sellerLoginManager.GetUser();

            return(RedirectToAction(nameof(Index), "Home", new { area = "Seller" }));
        }
Пример #3
0
        public async Task <UsedGamesAPILoginResponse> LoginAsync(UserLoginDTO userDTO)
        {
            string jsonUser = JsonConvert.SerializeObject(userDTO);
            HttpResponseMessage responseMsg = await _client.PostAsync(_client.BaseAddress + "login", new StringContent(jsonUser, Encoding.UTF8, "application/json"));

            UsedGamesAPILoginResponse response = new UsedGamesAPILoginResponse(responseMsg.IsSuccessStatusCode);

            if (!response.Success)
            {
                return(response);
            }
            string responseStr = await responseMsg.Content.ReadAsStringAsync();

            response         = JsonConvert.DeserializeObject <UsedGamesAPILoginResponse>(responseStr);
            response.Success = responseMsg.IsSuccessStatusCode;
            return(response);
        }