コード例 #1
0
        protected override void Approve(string userName, CampaignState newState, Campaign context)
        {
            string message = String.Format("{0} approved {1} campaign {2}", userName, context.State.Name, this.Name);

            AdvertiserNotificationService.NotifyAdvertiser(context.Advertiser, message);
            context.State         = newState;
            context.LastUpdatedBy = userName;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        protected virtual void Approve(string userName, CampaignState newState, Campaign context)
        {
            // Delete body once parts are all moved to subclasses
            // For invalid options, consider leaving exceptions in the base implementation

            //if (context.State == CampaignState.Approved)
            //{
            //    throw new InvalidOperationException("Can't approve a campaign once it has already been approved.");
            //}
            //if (context.State == CampaignState.Completed)
            //{
            //    throw new InvalidOperationException("Can't approve a campaign once it has completed.");
            //}
            //if (context.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, context.State.Name, this.Name);
            //AdvertiserNotificationService.NotifyAdvertiser(context.Advertiser, message);
            //context.State = newState;
            //context.LastUpdatedBy = userName;
        }
コード例 #5
0
        public void UpdateStatus(string newStatus, string userName)
        {
            CampaignState newState = CampaignState.ForStatus(newStatus);

            if (newState == CampaignState.Cancelled)
            {
                Cancel(userName, newState);
            }
            else if (newState == CampaignState.Pending)
            {
                MarkPending();
            }
            else if (newState == CampaignState.Approved)
            {
                Approve(userName, newState);
            }
            else if (newState == CampaignState.Active)
            {
            }
            else if (newState == CampaignState.Completed)
            {
            }
        }
コード例 #6
0
 protected override void Approve(string userName, CampaignState newState, Campaign context)
 {
     throw new InvalidOperationException("Can't approve a campaign once it has completed.");
 }