예제 #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);
        }
예제 #2
0
        public async Task <IActionResult> ProfileClientUser(ProfileClientUserVM model)
        {
            bool _checkSession = CheckSession();

            if (_checkSession)
            {
                return(RedirectToAction(nameof(Logout)));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    var result = await _client.ProfileClientUser(model);

                    if (result != null)
                    {
                        _logger.LogInformation($"profile client user successfully....");
                        TempData["msg"] = $"Client user created successfully";
                        return(RedirectToAction(nameof(ProfileClientUser)));
                    }
                    else
                    {
                        _logger.LogInformation($"creating profile client Unsuccessful....");
                        ViewBag.msg = $"Could not profile client user";
                    }
                }
                else
                {
                    _logger.LogInformation($"Invalid model state....", model);
                    //ViewData["msg"] = $"Please fill out all fields";
                    ViewBag.msg = $"Please fill out all fields";
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"{ex?.InnerException?.InnerException?.Message}");
            }
            return(RedirectToAction(nameof(ProfileClientUser)));
        }
예제 #3
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));
        }