/// <summary> /// Load all campaigns from the database. /// </summary> /// <returns></returns> private CampaignSet LoadCampaignSet() { var campaignSet = new CampaignSet(); // Get the collection from the ORM data layer var metaData = new LinqMetaData(); IQueryable <CampaignEntity> campaigns = from c in metaData.Campaign select c; var campaignCollection = ((ILLBLGenProQuery)campaigns).Execute <CampaignCollection>(); // Fill the entity set from the data collection if (campaignCollection.Count > 0) { foreach (var campaignEntity in campaignCollection) { var campaign = new Campaign(campaignEntity); campaign.CampaignType = ServiceManagerProvider.GetCampaignTypeManager().GetCampaignType(campaign.CampaignTypeId); campaign.RedemptionCode = ServiceManagerProvider.GetRedemptionCodeManager().GetRedemptionCode(campaign.RedemptionCodeId); campaignSet.Add(campaign); } } // Return the entity set return(campaignSet); }
/// <summary> /// Load a campaign from the database given its Id. /// </summary> /// <returns></returns> private Campaign LoadCampaign(int campaignId) { var campaign = new Campaign(new CampaignEntity(campaignId)); campaign.CampaignType = ServiceManagerProvider.GetCampaignTypeManager().GetCampaignType(campaign.CampaignTypeId); campaign.RedemptionCode = ServiceManagerProvider.GetRedemptionCodeManager().GetRedemptionCode(campaign.RedemptionCodeId); return(campaign); }