public async Task <ActionResult> AddNewAddress(UserAddressPostModel userAddressPostModel) { if (!_userAddressService.IsValidAddress(userAddressPostModel)) { return(Ok(new { error_message = "Cu phap khong hop le" })); } User user = await _userServices.GetUserById(userAddressPostModel.UserId); if (user is null) { return(Ok(new { error_message = "Khong ton tai User" })); } DistrictAddress districtAddress = await _cityServices.GetCityAndDistrictAsync(userAddressPostModel); if (districtAddress is null) { return(Ok(new { error_message = "Khong ton tai dia chi nay" })); } await _userAddressService.SetAllUserAddressToFalseAsync(userAddressPostModel.UserId); UserAddress userAddress = _mapper.Map <UserAddress>(userAddressPostModel); bool isSaveUserAddress = await _userAddressService.AddUserAddress(userAddress); if (isSaveUserAddress) { return(Ok(new { data = userAddress })); } else { return(Ok(new { error_message = "Co loi khi them dia chi moi" })); } }