public ActionResult EditKeyword(long keywordGK) { Models.KeywordModel m = new Models.KeywordModel(); using (var client = new OltpLogicClient(session_id)) { m.Keyword = client.Service.Keyword_GetSingle(keywordGK)[0]; Oltp.AdgroupDataTable keyword_adgroups = client.Service.Adgroup_GetByKeyword(keywordGK); Dictionary <int, Oltp.CampaignRow> campaings_dictionaty = client.Service.Campaign_GetIndividualCampaigns(keyword_adgroups.Select(f => f.CampaignGK).ToArray()).ToDictionary(f => f.GK, f => f); foreach (Oltp.AdgroupRow r in keyword_adgroups) { m.Associations.Add(new Models.AssociationRowModel() { AdGroup = r, Campaign = campaings_dictionaty[(int)r.CampaignGK] }); } } return(PartialView("~/Views/Keywords/KeywordDetails.cshtml", m)); }
public ActionResult EditCreative(long creativeGK) { Models.CreativeModel m = new Models.CreativeModel(); using (OltpLogicClient client = OltpLogicClient.Open(session_id)) { if (client == null) { return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml")); } Oltp.CreativeRow creative = client.Service.Creative_GetSingle(creativeGK)[0]; m.Creative = creative; Oltp.SegmentDataTable segments = client.Service.Segment_Get(acc_id, false); foreach (Oltp.SegmentRow r in segments) { bool is_creative_segment = ((Auxilary.SegmentAssociationFlags)r.Association).HasFlag(Auxilary.SegmentAssociationFlags.Creative); if (is_creative_segment) { Oltp.SegmentValueDataTable values = client.Service.SegmentValue_Get(acc_id, r.SegmentID); int value; switch (r.SegmentID) { case 1: value = creative.Segment1; break; case 2: value = creative.Segment2; break; case 3: value = creative.Segment3; break; case 4: value = creative.Segment4; break; case 5: value = creative.Segment5; break; default: value = creative.Segment1; break; } m.Segments.Add(new Models.SegmentRowModel() { SegmentRow = r, Values = values.ToList(), SelectedValue = value }); } } Oltp.AdgroupDataTable creative_adgroups = client.Service.Adgroup_GetByCreative(creativeGK); Dictionary <int, Oltp.CampaignRow> campaings_dictionaty = client.Service.Campaign_GetIndividualCampaigns(creative_adgroups.Select(f => f.CampaignGK).ToArray()).ToDictionary(f => f.GK, f => f); foreach (Oltp.AdgroupRow r in creative_adgroups) { m.Associations.Add(new Models.AssociationRowModel() { AdGroup = r, Campaign = campaings_dictionaty[(int)r.CampaignGK] }); } m.Creative = creative; } return(PartialView("~/Views/Creatives/CreativeDetails.cshtml", m)); }