Exemplo n.º 1
0
        public async Task <ProfileClientUser> ProfileClientUser(ProfileClientUserVM model)
        {
            ProfileClientUser res = null;

            try
            {
                var        endpoint = _configuration.GetSection("API").GetSection("registerClientUser").Value;
                HttpClient client   = _apiHelper.InitializeClient();
                model.profileClientUser.password = _base64Helper.convertToBase64(model.profileClientUser.password);
                var         json = JsonConvert.SerializeObject(model.profileClientUser);
                HttpContent registrationDetails = new StringContent(json, Encoding.UTF8, "application/json");
                var         response            = await client.PostAsync(endpoint, registrationDetails);

                if (response.IsSuccessStatusCode)
                {
                    res = JsonConvert.DeserializeObject <ProfileClientUser>(await response.Content.ReadAsStringAsync());
                }
                else
                {
                    res = JsonConvert.DeserializeObject <ProfileClientUser>(await response.Content.ReadAsStringAsync());
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation($"{ex?.InnerException?.InnerException?.Message}");
            }
            return(res);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ProfileClientUser()
        {
            ProfileClientUserVM clientUserVM = new ProfileClientUserVM();
            bool _checkSession = CheckSession();

            if (_checkSession)
            {
                return(RedirectToAction(nameof(Logout)));
            }
            try
            {
                var getClients = await _client.GetAllClients();

                var profile = new ProfileClientUser();
                clientUserVM.clients           = getClients;
                clientUserVM.profileClientUser = profile;
            }
            catch (Exception ex)
            {
                _logger.LogError($"{ex?.InnerException?.InnerException?.Message}");
            }
            return(View(clientUserVM));
        }