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" })); } }
/// <summary> /// Returns true if OwnerVerificationPdfViewModel instances are equal /// </summary> /// <param name="other">Instance of OwnerVerificationPdfViewModel to be compared</param> /// <returns>Boolean</returns> public bool Equals(OwnerVerificationPdfViewModel other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( ReportDate == other.ReportDate || ReportDate.Equals(other.ReportDate) ) && ( Title == other.Title || Title.Equals(other.Title) ) && ( DistrictId == other.DistrictId || DistrictId.Equals(other.DistrictId) ) && ( MinistryDistrictId == other.MinistryDistrictId || MinistryDistrictId.Equals(other.MinistryDistrictId) ) && ( DistrictName == other.DistrictName || DistrictName.Equals(other.DistrictName) ) && ( DistrictAddress == other.DistrictAddress || DistrictAddress.Equals(other.DistrictAddress) ) && ( DistrictContact == other.DistrictContact || DistrictContact.Equals(other.DistrictContact) ) && ( Owners == other.Owners || Owners.Equals(other.Owners) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks hash = hash * 59 + ReportDate.GetHashCode(); hash = hash * 59 + Title.GetHashCode(); hash = hash * 59 + DistrictId.GetHashCode(); hash = hash * 59 + MinistryDistrictId.GetHashCode(); hash = hash * 59 + DistrictName.GetHashCode(); hash = hash * 59 + DistrictAddress.GetHashCode(); hash = hash * 59 + DistrictContact.GetHashCode(); hash = hash * 59 + Owners.GetHashCode(); return(hash); } }