Exemplo n.º 1
0
        protected async Task <bool> OnSaveAsync(UserDto userDto)
        {
            var userCreateOrEditDto = new UserCreateOrEditDto
            {
                Id       = Guid.Parse(userDto.UserId),
                Username = userDto.Username,
                Password = userDto.Password,
                Enabled  = userDto.EnabledAddOrEdit
            };
            ResultModel <string> result = new ResultModel <string>();

            if (string.IsNullOrWhiteSpace(userDto.UserId))
            {
                result = await UserService.AddUser(userCreateOrEditDto);
            }
            else
            {
                result = await UserService.EditUser(userCreateOrEditDto);
            }
            if (result.status.code == ResultCode.Success)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public async Task <ResultModel <string> > EditUser(UserCreateOrEditDto dto)
        {
            var userJson = new StringContent(JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json");
            var response = await _httpClient.PostAsync($"api/Users/UpdateUser", userJson);

            if (response.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <ResultModel <string> >(await response.Content.ReadAsStringAsync()));
            }
            return(null);
        }