public string InsertAdDeploymentPeriod(int campaignId, int adid, int deploymentPeriodId, bool applyAllDeployments) { string retVal = string.Empty; try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { int applyToAllDeployment = 0; if (applyAllDeployments) { applyToAllDeployment = 1; } ACM.DAO.DeploymentPeriodDAO dao = new DeploymentPeriodDAO(); var allDeploymentPeriods = dao.GetFutureDeploymentPeriod(campaignId, deploymentPeriodId); List <string> ads = new List <string>(); foreach (var item in allDeploymentPeriods) { ads.Add(item.ID.ToString()); } string adList = string.Join(",", ads.ToList()); ctx.Database.ExecuteSqlCommand("SP_AddDeploymentPeriod @CampaignId, @AdId, @DeploymentPeriodId,@DeploymentPeriodIds, @applyAll", new SqlParameter("CampaignId", campaignId), new SqlParameter("AdId", adid), new SqlParameter("DeploymentPeriodId", deploymentPeriodId), new SqlParameter("DeploymentPeriodIds", adList), new SqlParameter("applyAll", applyToAllDeployment) ); } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "InsertAdDeploymentPeriod"); throw; } return(retVal); }
public List<ACM.Model.DeploymentPeriod> GetAllDeploymentPeriods() { DeploymentPeriodDAO deploymentPeriodDAO = new DeploymentPeriodDAO(); return deploymentPeriodDAO.GetAllDeploymentPeriods(); }
public string InsertAdDeploymentPeriod(int campaignId, int adid, int deploymentPeriodId, bool applyAllDeployments) { string retVal = string.Empty; try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { int applyToAllDeployment = 0; if (applyAllDeployments) applyToAllDeployment = 1; ACM.DAO.DeploymentPeriodDAO dao = new DeploymentPeriodDAO(); var allDeploymentPeriods = dao.GetFutureDeploymentPeriod(campaignId, deploymentPeriodId); List<string> ads = new List<string>(); foreach (var item in allDeploymentPeriods) { ads.Add(item.ID.ToString()); } string adList = string.Join(",", ads.ToList()); ctx.Database.ExecuteSqlCommand("SP_AddDeploymentPeriod @CampaignId, @AdId, @DeploymentPeriodId,@DeploymentPeriodIds, @applyAll", new SqlParameter("CampaignId", campaignId), new SqlParameter("AdId", adid), new SqlParameter("DeploymentPeriodId", deploymentPeriodId), new SqlParameter("DeploymentPeriodIds", adList), new SqlParameter("applyAll", applyToAllDeployment) ); } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "InsertAdDeploymentPeriod"); throw; } return retVal; }