v1.2.6.3
This commit is contained in:
@@ -99,7 +99,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
data.ContactMethods.Add(new AjaxResponse_Data.ContactMethodData() { Method = method.ToString(), MethodCaption = Localiser.GetContactMethodCaption(method), Value = contactData.GetContactMethodValue(method) });
|
||||
}
|
||||
// Address.
|
||||
if (address != null)
|
||||
if (address != null && !address.IsStatusDeleted)
|
||||
{
|
||||
data.Address = new AjaxResponse_Data.AddressData();
|
||||
data.Address.Id = model.EncryptId(address.Id);
|
||||
@@ -384,7 +384,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
organisationAddress = ItemDataMgr.CreateItemAddress(organisation.GetItemId(), SaxItemAddress.DefaultOrganisationAddressType);
|
||||
disposableItems.Add(organisationAddress);
|
||||
}
|
||||
else
|
||||
else if (!organisationAddress.IsStatusDeleted)
|
||||
{
|
||||
SaLogger.Warn(fn + " Organisation Address Id not supplied but no address found for Organisation. Id: " + organisationAddress.Id + ". " + GetLogSuffix());
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
@@ -450,51 +450,71 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
|
||||
}
|
||||
|
||||
// Store address.
|
||||
if (model.Organisation.Address.Line1 != null)
|
||||
organisationAddress.Line1 = model.Organisation.Address.Line1;
|
||||
if (model.Organisation.Address.Line2 != null)
|
||||
organisationAddress.Line2 = model.Organisation.Address.Line2;
|
||||
if (model.Organisation.Address.Line3 != null)
|
||||
organisationAddress.Line3 = model.Organisation.Address.Line3;
|
||||
if (model.Organisation.Address.Town != null)
|
||||
organisationAddress.Town = model.Organisation.Address.Town;
|
||||
if (regionProvince != null)
|
||||
if (model.Organisation.Address.IsSpecified())
|
||||
{
|
||||
organisationAddress.Province = regionProvince.Name;
|
||||
organisationAddress.RegionIdProvince = regionProvince.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.Organisation.Address.Province != null)
|
||||
organisationAddress.Province = model.Organisation.Address.Province;
|
||||
}
|
||||
if (regionCountry != null)
|
||||
{
|
||||
organisationAddress.Country = regionCountry.Name;
|
||||
organisationAddress.RegionIdCountry = regionCountry.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.Organisation.Address.Country != null)
|
||||
organisationAddress.Country = model.Organisation.Address.Country;
|
||||
}
|
||||
organisationAddress.PostalCode = model.Organisation.Address.PostalCode;
|
||||
if (!SysId.IsValid(organisationAddress.Id))
|
||||
{
|
||||
// Create new address.
|
||||
if (!ItemDataMgr.InsertItemAddress(organisationAddress, DbUpdateInfo))
|
||||
// The form includes address fields.
|
||||
if (model.Organisation.Address.IsPopulated())
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert organisation address - " + ItemDataMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
// At least one address field has been populated.
|
||||
if (model.Organisation.Address.Line1 != null)
|
||||
organisationAddress.Line1 = model.Organisation.Address.Line1;
|
||||
if (model.Organisation.Address.Line2 != null)
|
||||
organisationAddress.Line2 = model.Organisation.Address.Line2;
|
||||
if (model.Organisation.Address.Line3 != null)
|
||||
organisationAddress.Line3 = model.Organisation.Address.Line3;
|
||||
if (model.Organisation.Address.Town != null)
|
||||
organisationAddress.Town = model.Organisation.Address.Town;
|
||||
if (regionProvince != null)
|
||||
{
|
||||
organisationAddress.Province = regionProvince.Name;
|
||||
organisationAddress.RegionIdProvince = regionProvince.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.Organisation.Address.Province != null)
|
||||
organisationAddress.Province = model.Organisation.Address.Province;
|
||||
}
|
||||
if (regionCountry != null)
|
||||
{
|
||||
organisationAddress.Country = regionCountry.Name;
|
||||
organisationAddress.RegionIdCountry = regionCountry.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.Organisation.Address.Country != null)
|
||||
organisationAddress.Country = model.Organisation.Address.Country;
|
||||
}
|
||||
organisationAddress.PostalCode = model.Organisation.Address.PostalCode;
|
||||
organisationAddress.Status = SaxItemAddress.DefaultStatus;
|
||||
|
||||
// Store address.
|
||||
if (!SysId.IsValid(organisationAddress.Id))
|
||||
{
|
||||
// Create new address.
|
||||
if (!ItemDataMgr.InsertItemAddress(organisationAddress, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert organisation address - " + ItemDataMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update existing address.
|
||||
if (!ItemDataMgr.UpdateItemAddress(organisationAddress, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update organisation address - " + ItemDataMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update existing address.
|
||||
if (!ItemDataMgr.UpdateItemAddress(organisationAddress, DbUpdateInfo))
|
||||
else
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update organisation address - " + ItemDataMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
// Address not specified - delete it.
|
||||
if (!ItemDataMgr.DeleteItemAddress(organisationAddress, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to delete organisation address - " + ItemDataMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user