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);
        }