Skip to content

Instantly share code, notes, and snippets.

@mps
Created August 9, 2011 20:29
Show Gist options
  • Save mps/1135111 to your computer and use it in GitHub Desktop.
Save mps/1135111 to your computer and use it in GitHub Desktop.
Proposed Upload change
protected virtual void OnUploadCommandExecute(object debugObj)
{
UploadDebug = debugObj == null ? false : debugObj.Equals("true");
var dateDiff = Policy.EffectiveDt.Subtract(DateTime.UtcNow);
if (dateDiff.Days > 30 || dateDiff.Days < 0)
{
AlertWindow.Alert("Cannot upload a policy unless the effective date is within 30 days of today.", "Invalid effective date");
return;
}
if (ApplicationModel.Current.Agency == null)
return;
if (ApplicationModel.Current.Agent == null)
return;
var location = ApplicationModel.Current.Agency.GetLocation(ApplicationModel.Current.Agent.AgencyLocationId);
var producer = new ProducerInfo(ApplicationModel.Current.Agent, location, Rate.CompanyInitials);
if (string.IsNullOrEmpty(producer.ProducerCode))
{
AlertWindow.Alert("A valid producer code is required to upload a policy.", "Invalid producer code");
return;
}
if (!Policy.ValidateVinsForUpload())
{
AlertWindow.Alert("A valid 17 digit VIN is required on all Vehicles prior to an Upload.", "Invalid VIN(s).");
return;
}
if (RequiresSocialAndLicenseForUpload())
{
if (Policy.Drivers.Any(d => (d.DriverStatusCd != DriverStatus.Excluded) && (d.DriverStatusCd != DriverStatus.NonRated) && (string.IsNullOrWhiteSpace(d.Ssn) || string.IsNullOrWhiteSpace(d.LicenseNumber))))
{
AlertWindow.Alert("A SSN and driver's license number must be entered for all rated drivers prior to upload.", "Missing driver info");
return;
}
}
CanUpload = false;
StartUpload();
}
public bool RequiresSocialAndLicenseForUpload()
{
// GA PCW
if ((Rate.CompanyInitials.Equals("PCW", StringComparison.OrdinalIgnoreCase) && ApplicationModel.Current.Agent.StateCd == State.GA))
return false;
// FL PTC
if ((Rate.CompanyInitials.Equals("PTC", StringComparison.OrdinalIgnoreCase) && ApplicationModel.Current.Agent.StateCd == State.FL))
return false;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment