public class SubmissionModelLayer : SubmissionModel
{
public event EventHandler SubmissionCompleteEvent;
public event EventHandler SubmissionIncompleteEvent;
private SubmittedApplication mApplication;
private ServiceLocater mLocater;
public SubmissionModelLayer(ServiceLocater locater)
{
mLocater = locater;
}
public void SubmitApplication(SubmittedApplication application)
{
mApplication = application;
mApplication.ValidateApplication(mLocater.GetValidationService());
if(IsNotValidSubmisssion())
return;
mApplication.StoreApplication(mLocater.GetDataService());
if(IsNotStoredSubmission())
return;
mApplication.NotifyCustomer(mLocater.GetMessageService());
if (IsNotNotifiedSubmission())
return;
Fire_CompleteEvent();
}
private bool IsNotNotifiedSubmission()
{
if (!mApplication.IsCustomerNotified)
{
Fire_InCompleteEvent();
return true;
}
return false;
}
private bool IsNotStoredSubmission()
{
if (!mApplication.IsStored)
{
Fire_InCompleteEvent();
return true;
}
return false;
}
private bool IsNotValidSubmisssion()
{
if (!mApplication.IsValid)
{
Fire_InCompleteEvent();
return true;
}
return false;
}
private void Fire_InCompleteEvent()
{
if (SubmissionIncompleteEvent != null)
SubmissionIncompleteEvent.Invoke(null, EventArgs.Empty);
}
private void Fire_CompleteEvent()
{
if (SubmissionCompleteEvent != null)
SubmissionCompleteEvent.Invoke(null, EventArgs.Empty);
}
}
No comments:
Post a Comment