Académique Documents
Professionnel Documents
Culture Documents
cs
/// <summary>
/// Get Country Details based on country code.
/// </summary>
/// <param name="countryCode">Country code</param>
/// <returns>Datatable consist country configurations.</returns>
public DataTable GetCountryData(string countryCode)
{
using (TraceManager loTraceManager = new
TraceManager("DG.Provider.DataLayer.GetCountryData"))
{
try
{
loTraceManager.AddInformation("Creating Database Connection
object.");
Database loDBConnection =
DBConnectionCertificate.GetDatabase();
using (DbCommand loDBCommand =
loDBConnection.GetStoredProcCommand(LOCATION_GETCOUNTRYDATA, countryCode, "en-US"))
{
loTraceManager.AddInformation("Before Execute query...");
}
catch (FaultException<string>)
{
throw;
}
catch (Exception ex)
{
loTraceManager.AddInformation(ex.Message.ToString());
//Add various items to the Exception.Data dictionary:
ex.SetExceptionType(DG.ExceptionTools.Library.ExceptionTypeEnum.GeneralError);
--------------------------------------------------------------------
SearchRequestValidator.cs
private bool ValidateStreetAddress(StreetAddress address)
{
//ToDo: Check for Place ID
//return !string.IsNullOrEmpty(address.AddressLine1) && !
string.IsNullOrEmpty(address.CountryCode) && !
string.IsNullOrEmpty(address.PostalCode);
//DG.Provider.Library.LocationBLService.CountryData ;
DataTable countryZipCode = GetCountryData(address.CountryCode);
bool IsZipRequired;
if (countryZipCode != null && countryZipCode.Rows.Count > 0)
{
IsZipRequired = Convert.ToBoolean(countryZipCode.Rows[0]
["IsZipRequired"]);
if (Convert.ToBoolean(countryZipCode.Rows[0]["IsZipRequired"]) ==
true)
{
return !string.IsNullOrEmpty(address.AddressLine1) && !
string.IsNullOrEmpty(address.CountryCode) && !
string.IsNullOrEmpty(address.PostalCode);
}
}
return !string.IsNullOrEmpty(address.AddressLine1) && !
string.IsNullOrEmpty(address.CountryCode);
}
===================================================================================
=============
bool IsZipRequired;
DG.Location.Library.Location loc = new DG.Location.Library.Location();
DataTable countryZipCode = loc.GetCountryData(address.CountryCode);
if (IsZipRequired == true)
{
return !string.IsNullOrEmpty(address.AddressLine1) && !
string.IsNullOrEmpty(address.CountryCode) && !
string.IsNullOrEmpty(address.PostalCode);
}
}
return !string.IsNullOrEmpty(address.AddressLine1) && !
string.IsNullOrEmpty(address.CountryCode);