public void Add(LandingPageDTO landingPage)
 {
     p1p.Data.LandingPage mdlLandingPage = (p1p.Data.LandingPage)P1PObjectMapper.Convert(landingPage, typeof(p1p.Data.LandingPage));
     mdlLandingPage.InsertDate = DateTime.Now;
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         ctx.LandingPages.Add(mdlLandingPage);
         ctx.SaveChanges();
     }
 }
 public void Update(LandingPageDTO landingPage)
 {
     p1p.Data.LandingPage mdlLandingPage = (p1p.Data.LandingPage)P1PObjectMapper.Convert(landingPage, typeof(p1p.Data.LandingPage));
     p1p.Data.LandingPage match;
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         match = ctx.LandingPages.Single(l => landingPage.Id == l.Id);
         ctx.Entry(match).CurrentValues.SetValues(mdlLandingPage);
         ctx.SaveChanges();
     }
 }
 public void UpdateLandingPage(LandingPageDTO item)
 {
     p1p.Data.LandingPage            mdlLandingPage = (p1p.Data.LandingPage)P1PObjectMapper.Convert(item, typeof(p1p.Data.LandingPage));
     p1p.Data.LandingPage            match;
     p1p.Data.ProjectLandingPageXREF xmatch;
     p1p.Data.ProjectLandingPageXREF newxref;
     using (P1PContext ctx = new P1PContext())
     {
         match = ctx.LandingPages.Single(l => l.Id == item.Id);
         mdlLandingPage.InsertDate = match.InsertDate;
         ctx.Entry(match).CurrentValues.SetValues(mdlLandingPage);
         xmatch  = ctx.ProjectLandingPageXREFs.Single(x => x.LandingPageId == item.Id);
         newxref = xmatch;
         newxref.LandingPagePriority = item.Priority;
         ctx.Entry(xmatch).CurrentValues.SetValues(newxref);
         ctx.SaveChanges();
     }
 }
        public void AddLandingPage(LandingPageDetailDTO item)
        {
            p1p.Data.LandingPage newLandingPage;
            p1p.Data.LandingPage mdlLandingPage = (p1p.Data.LandingPage)P1PObjectMapper.Convert(item, typeof(p1p.Data.LandingPage));
            mdlLandingPage.InsertDate = DateTime.Now;
            using (P1PContext ctx = new P1PContext())
            {
                newLandingPage = ctx.LandingPages.Add(mdlLandingPage);
                ctx.ProjectLandingPageXREFs.Add(new ProjectLandingPageXREF()
                {
                    ProjectId           = item.ProjectId,
                    LandingPageId       = newLandingPage.Id,
                    LandingPagePriority = item.Priority,
                    InsertDate          = DateTime.Now
                });

                ctx.SaveChanges();
            }
        }