private void Cancel(string userName, CampaignState newState, Campaign context) { if (context.State == CampaignState.Cancelled) { throw new InvalidOperationException("Can't cancel a campaign that is already cancelled."); } if (context.State == CampaignState.Completed) { throw new InvalidOperationException("Can't cancel a campaign once it has completed."); } string message = String.Format("{0} cancelled {1} campaign {2}", userName, context.State.Name, this.Name); AdvertiserNotificationService.NotifyAdvertiser(context.Advertiser, message); context.State = newState; context.LastUpdatedBy = userName; }
private void Approve(string userName, CampaignState newState) { if (this.State == CampaignState.Approved) { throw new InvalidOperationException("Can't approve a campaign once it has already been approved."); } if (this.State == CampaignState.Completed) { throw new InvalidOperationException("Can't approve a campaign once it has completed."); } if (this.State == CampaignState.Active) { throw new InvalidOperationException("Can't approve a campaign once it is active."); } string message = String.Format("{0} approved {1} campaign {2}", userName, this.State.Name, this.Name); AdvertiserNotificationService.NotifyAdvertiser(this.Advertiser, message); this.State = newState; this.LastUpdatedBy = userName; }