public void UpdateKeyword(KeywordDetailDTO item)
        {
            p1p.Data.Keyword                mdlKeyword = (p1p.Data.Keyword)P1PObjectMapper.Convert(item, typeof(p1p.Data.Keyword));
            p1p.Data.Keyword                match;
            p1p.Data.ProjectKeywordXREF     xmatch;
            p1p.Data.ProjectKeywordXREF     newxref;
            p1p.Data.LandingPageKeywordXREF lpxmatch;
            p1p.Data.LandingPageKeywordXREF newlpxref;
            using (P1PContext ctx = new P1PContext())
            {
                match = ctx.Keywords.Single(k => k.Id == item.Id);
                mdlKeyword.InsertDate = match.InsertDate;
                ctx.Entry(match).CurrentValues.SetValues(mdlKeyword);
                xmatch  = ctx.ProjectKeywordXREFs.Single(x => x.KeywordId == item.Id);
                newxref = xmatch;
                newxref.KeywordPriority = item.ProjectPriority;

                if (item.LandingPagePriority != 0)
                {
                    lpxmatch = ctx.LandingPageKeywordXREFs.FirstOrDefault(l => l.KeywordId == item.Id && l.LandingPageId == item.LandingPageId);
                    if (lpxmatch != null)
                    {
                        newlpxref = lpxmatch;
                        newlpxref.KeywordPriority = item.LandingPagePriority;
                        ctx.Entry(lpxmatch).CurrentValues.SetValues(newlpxref);
                    }
                }
                ctx.SaveChanges();
            }
        }
 public void AddKeyword(KeywordDetailDTO item)
 {
     p1p.Data.Keyword newKeyword;
     p1p.Data.Keyword mdlKeyword = (p1p.Data.Keyword)P1PObjectMapper.Convert(item, typeof(p1p.Data.Keyword));
     mdlKeyword.InsertDate = DateTime.Now;
     using (P1PContext ctx = new P1PContext())
     {
         newKeyword = ctx.Keywords.Add(mdlKeyword);
         ctx.ProjectKeywordXREFs.Add(new ProjectKeywordXREF()
         {
             ProjectId       = item.ProjectId,
             KeywordId       = newKeyword.Id,
             KeywordPriority = item.ProjectPriority,
             InsertDate      = DateTime.Now
         });
         ctx.SaveChanges();
     }
 }
Esempio n. 3
0
 public void UpdateKeyword(KeywordDetailDTO item)
 {
     repo.UpdateKeyword(item);
 }
Esempio n. 4
0
 public void AddKeyword(KeywordDetailDTO item)
 {
     repo.AddKeyword(item);
 }