public ACM.Model.CustomModel.AdInfo AdInfoInq(int campaignId, int adid, int deploymentPeriodId) { ACM.Model.CustomModel.AdInfo adInfo = new Model.CustomModel.AdInfo(); List <AdRestrictions> listRes = new List <AdRestrictions>(); try { using (ctx = new ACM_Redesign2014Context()) { var listItems = (ctx.Database.SqlQuery <AdInfo_Result>("AdInfo @DeploymentPeriodId, @CampaignId, @Adid", new SqlParameter("DeploymentPeriodId", deploymentPeriodId), new SqlParameter("CampaignId", campaignId), new SqlParameter("Adid", adid) )).SingleOrDefault(); adInfo.Ad = listItems; var adResInfo = (from ad in ctx.AdRestrictionAds where ad.CampaignId == campaignId && ad.AdId == adid select new { Id = ad.Id, AdRestrictionId = ad.AdRestrictionId, AdId = ad.AdId, CampaignId = ad.CampaignId }).ToList(); AdRestrictions adRes = new AdRestrictions(); foreach (var item in adResInfo) { adRes = new AdRestrictions(); adRes.AdId = item.AdId; adRes.AdRestrictionId = item.AdRestrictionId; adRes.CampaignId = item.CampaignId; adRes.Id = item.Id; listRes.Add(adRes); } adInfo.AdRestriction = listRes; } return(adInfo); } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "GetMasterDropDownDataforMasterTables"); throw; } }
public ActionResult AdDetailView(ACM.Model.Ad ad) { var adLocation = adServiceClient.AdLocationsByCampaign(ad.CampaignId, ad.AdId); ViewBag.adLocation = new SelectList(adLocation, "AdLocationCode", "AdLocationDesc"); ACM.Service.Client.AdServiceRef.AdServiceClient adProxy = new ACM.Service.Client.AdServiceRef.AdServiceClient(); ViewBag.restrictions = adServiceClient.GetAdRestrictionCategory(); var adproductType = ACM.Util.Common.GetDropDownListByID("ProductTypeId", "Description", "AdProductType"); ViewBag.adproductType = new SelectList(adproductType, "ID", "Name"); var flags = adServiceClient.GetAdRestrictionFlag(ad.CampaignId, ad.AdId); ViewBag.depositoryVal = null; ViewBag.eFcutoffVal = null; ViewBag.otherVal = null; //read restriction flags for edit mode foreach (KeyValuePair <int, int> dictItem in flags) { switch (dictItem.Key) { case (Int32)AdRestrictionFlag.DepositoryType: ViewBag.depositoryVal = dictItem.Value; break; case (Int32)AdRestrictionFlag.EFcutoff: ViewBag.eFcutoffVal = dictItem.Value; break; case (Int32)AdRestrictionFlag.Other: ViewBag.otherVal = dictItem.Value; break; } } int deploymentPeriodId = 0; AdInfo adInfoInq = new AdInfo(); if (Session["DeploymentPeriodId"] != null) { deploymentPeriodId = (int)Session["DeploymentPeriodId"]; } if (ad.AdId > 0) { adInfoInq = adServiceClient.AdInfoInq(ad.CampaignId, ad.AdId, deploymentPeriodId); if (adInfoInq.Ad == null) { adInfoInq = new Model.CustomModel.AdInfo(); adInfoInq.Ad = new AdInfo_Result(); adInfoInq.Ad.CampaignId = (Int32)Session["CampaignId"]; adInfoInq.AdRestriction = new List <Model.AdRestrictions>(); } if (adInfoInq.Ad.AdLocationCode != null) { var adlocationValue = adLocation.Find(x => x.AdLocationCode == adInfoInq.Ad.AdLocationCode); ViewBag.adlocationName = adlocationValue.AdLocationDesc; ViewBag.adlocationId = adInfoInq.Ad.AdLocationCode; } } else { adInfoInq = new Model.CustomModel.AdInfo(); adInfoInq.Ad = new AdInfo_Result(); adInfoInq.Ad.CampaignId = (Int32)Session["CampaignId"]; adInfoInq.AdRestriction = new List <Model.AdRestrictions>(); } return(PartialView(adInfoInq)); }
public ActionResult AdDetailView(ACM.Model.Ad ad) { var adLocation = adServiceClient.AdLocationsByCampaign(ad.CampaignId, ad.AdId); ViewBag.adLocation = new SelectList(adLocation, "AdLocationCode", "AdLocationDesc"); ACM.Service.Client.AdServiceRef.AdServiceClient adProxy = new ACM.Service.Client.AdServiceRef.AdServiceClient(); ViewBag.restrictions = adServiceClient.GetAdRestrictionCategory(); var adproductType = ACM.Util.Common.GetDropDownListByID("ProductTypeId", "Description", "AdProductType"); ViewBag.adproductType = new SelectList(adproductType, "ID", "Name"); var flags = adServiceClient.GetAdRestrictionFlag(ad.CampaignId, ad.AdId); ViewBag.depositoryVal = null; ViewBag.eFcutoffVal = null; ViewBag.otherVal = null; //read restriction flags for edit mode foreach (KeyValuePair<int, int> dictItem in flags) { switch (dictItem.Key) { case (Int32)AdRestrictionFlag.DepositoryType: ViewBag.depositoryVal = dictItem.Value; break; case (Int32)AdRestrictionFlag.EFcutoff: ViewBag.eFcutoffVal = dictItem.Value; break; case (Int32)AdRestrictionFlag.Other: ViewBag.otherVal = dictItem.Value; break; } } int deploymentPeriodId = 0; AdInfo adInfoInq = new AdInfo(); if (Session["DeploymentPeriodId"] != null) deploymentPeriodId = (int)Session["DeploymentPeriodId"]; if (ad.AdId > 0) { adInfoInq = adServiceClient.AdInfoInq(ad.CampaignId, ad.AdId, deploymentPeriodId); if (adInfoInq.Ad == null) { adInfoInq = new Model.CustomModel.AdInfo(); adInfoInq.Ad = new AdInfo_Result(); adInfoInq.Ad.CampaignId = (Int32)Session["CampaignId"]; adInfoInq.AdRestriction = new List<Model.AdRestrictions>(); } if (adInfoInq.Ad.AdLocationCode != null) { var adlocationValue = adLocation.Find(x => x.AdLocationCode == adInfoInq.Ad.AdLocationCode); ViewBag.adlocationName = adlocationValue.AdLocationDesc; ViewBag.adlocationId = adInfoInq.Ad.AdLocationCode; } } else { adInfoInq = new Model.CustomModel.AdInfo(); adInfoInq.Ad = new AdInfo_Result(); adInfoInq.Ad.CampaignId = (Int32)Session["CampaignId"]; adInfoInq.AdRestriction = new List<Model.AdRestrictions>(); } return PartialView(adInfoInq); }
public ACM.Model.CustomModel.AdInfo AdInfoInq(int campaignId, int adid, int deploymentPeriodId) { ACM.Model.CustomModel.AdInfo adInfo = new Model.CustomModel.AdInfo(); List<AdRestrictions> listRes = new List<AdRestrictions>(); try { using (ctx = new ACM_Redesign2014Context()) { var listItems = (ctx.Database.SqlQuery<AdInfo_Result>("AdInfo @DeploymentPeriodId, @CampaignId, @Adid", new SqlParameter("DeploymentPeriodId", deploymentPeriodId), new SqlParameter("CampaignId", campaignId), new SqlParameter("Adid", adid) )).SingleOrDefault(); adInfo.Ad = listItems; var adResInfo = (from ad in ctx.AdRestrictionAds where ad.CampaignId == campaignId && ad.AdId == adid select new { Id = ad.Id, AdRestrictionId = ad.AdRestrictionId, AdId = ad.AdId, CampaignId = ad.CampaignId }).ToList(); AdRestrictions adRes = new AdRestrictions(); foreach (var item in adResInfo) { adRes = new AdRestrictions(); adRes.AdId = item.AdId; adRes.AdRestrictionId = item.AdRestrictionId; adRes.CampaignId = item.CampaignId; adRes.Id = item.Id; listRes.Add(adRes); } adInfo.AdRestriction = listRes; } return adInfo; } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "GetMasterDropDownDataforMasterTables"); throw; } }