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 RemoveKeywordFromLandingPage(int landingPageId, int keywordId) { LandingPageKeywordXREF xref; using (P1PContext ctx = new P1PContext()) { xref = ctx.LandingPageKeywordXREFs.FirstOrDefault(x => x.LandingPageId == landingPageId && x.KeywordId == keywordId); ctx.LandingPageKeywordXREFs.Remove(xref); ctx.SaveChanges(); } }
public void UpdateProfile(CustomerDTO customer) { Customer cust = (Customer)P1PObjectMapper.Convert(customer, typeof(Customer)); using (P1PContext ctx = new P1PContext()) { Customer match = ctx.Customers.Single(c => c.Username.Equals(cust.Username)); ctx.Entry(match).CurrentValues.SetValues(cust); ctx.SaveChanges(); } }
public void UpdatePersona(PersonaDTO item) { p1p.Data.Persona mdlPersona = (p1p.Data.Persona)P1PObjectMapper.Convert(item, typeof(p1p.Data.Persona)); p1p.Data.Persona match; using (P1PContext ctx = new P1PContext()) { match = ctx.Personas.Single(p => p.Id == mdlPersona.Id); mdlPersona.InsertDate = match.InsertDate; ctx.Entry(match).CurrentValues.SetValues(mdlPersona); ctx.SaveChanges(); } }
public void UpdateSocialAccount(SocialAccountDTO item) { p1p.Data.SocialAccount mdlAccount = (p1p.Data.SocialAccount)P1PObjectMapper.Convert(item, typeof(p1p.Data.SocialAccount)); p1p.Data.SocialAccount match; using (P1PContext ctx = new P1PContext()) { match = ctx.SocialAccounts.Single(s => s.Id == mdlAccount.Id); mdlAccount.InsertDate = match.InsertDate; ctx.Entry(match).CurrentValues.SetValues(mdlAccount); ctx.SaveChanges(); } }
public ProjectDTO RemoveCategoryFromProject(int projectId, int categoryId) { OrderCategoryXREF xref; using (P1PContext ctx = new P1PContext()) { xref = ctx.OrderCategoryXREFs.Single(x => x.CategoryId == categoryId && x.ProjectId == projectId); ctx.OrderCategoryXREFs.Remove(xref); ctx.SaveChanges(); } return(GetProject(projectId)); }
public void DeletePersonaSocialAccount(int socialAccountId) { p1p.Data.SocialAccount acct; p1p.Data.PersonaSocialAccountXREF xref; using (P1PContext ctx = new P1PContext()) { xref = ctx.PersonaSocialAccountXREFs.FirstOrDefault(x => x.SocialAccountId == socialAccountId); ctx.PersonaSocialAccountXREFs.Remove(xref); acct = ctx.SocialAccounts.FirstOrDefault(a => a.Id == socialAccountId); ctx.SocialAccounts.Remove(acct); ctx.SaveChanges(); } }
public ProjectDTO AddCategoryToProject(int projectId, int categoryId) { p1p.Data.OrderCategoryXREF x = new OrderCategoryXREF() { ProjectId = projectId, CategoryId = categoryId }; using (P1PContext ctx = new P1PContext()) { ctx.OrderCategoryXREFs.Add(x); ctx.SaveChanges(); } return(GetProject(projectId)); }
public void AddKeywordToLandingPage(int landingPageId, int keywordId, int priority) { using (P1PContext ctx = new P1PContext()) { if (ctx.LandingPageKeywordXREFs.FirstOrDefault(x => x.KeywordId == keywordId && x.LandingPageId == landingPageId) == null) { ctx.LandingPageKeywordXREFs.Add(new LandingPageKeywordXREF() { LandingPageId = landingPageId, KeywordId = keywordId, InsertDate = DateTime.Now, KeywordPriority = priority }); ctx.SaveChanges(); } } }
public void AddPersonaSocialAccount(SocialAccountDetailDTO item) { p1p.Data.SocialAccount newSocialAccount; p1p.Data.SocialAccount mdlSocialAccount = (p1p.Data.SocialAccount)P1PObjectMapper.Convert(item, typeof(p1p.Data.SocialAccount)); mdlSocialAccount.InsertDate = DateTime.Now; using (P1PContext ctx = new P1PContext()) { newSocialAccount = ctx.SocialAccounts.Add(mdlSocialAccount); ctx.PersonaSocialAccountXREFs.Add(new PersonaSocialAccountXREF() { PersonaId = item.PersonaId, SocialAccountId = newSocialAccount.Id, InsertDate = DateTime.Now }); ctx.SaveChanges(); } }
public void AddPersona(PersonaDetailDTO item) { p1p.Data.Persona newPersona; p1p.Data.Persona mdlPersona = (p1p.Data.Persona)P1PObjectMapper.Convert(item, typeof(p1p.Data.Persona)); mdlPersona.InsertDate = DateTime.Now; using (P1PContext ctx = new P1PContext()) { newPersona = ctx.Personas.Add(mdlPersona); ctx.ProjectPersonaXREFs.Add(new ProjectPersonaXREF() { ProjectId = item.ProjectId, PersonaId = newPersona.Id, InsertDate = DateTime.Now }); 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 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(); } }
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(); } }
public void DeletePersona(int personaId) { p1p.Data.Persona persona; p1p.Data.ProjectPersonaXREF pxref; List <p1p.Data.PersonaSocialAccountXREF> xrefs; using (P1PContext ctx = new P1PContext()) { persona = ctx.Personas.Single(p => p.Id == personaId); xrefs = ctx.PersonaSocialAccountXREFs.Where(x => x.PersonaId == personaId).ToList <p1p.Data.PersonaSocialAccountXREF>(); foreach (PersonaSocialAccountXREF x in xrefs) { ctx.PersonaSocialAccountXREFs.Remove(x); } pxref = ctx.ProjectPersonaXREFs.Single(p => p.Id == personaId); ctx.ProjectPersonaXREFs.Remove(pxref); ctx.Personas.Remove(persona); ctx.SaveChanges(); } }
public void DeleteKeyword(int keywordId) { p1p.Data.Keyword keyword; List <p1p.Data.LandingPageKeywordXREF> lxrefs; p1p.Data.ProjectKeywordXREF pxref; using (P1PContext ctx = new P1PContext()) { keyword = ctx.Keywords.Single(k => k.Id == keywordId); pxref = ctx.ProjectKeywordXREFs.Single(x => x.KeywordId == keywordId); lxrefs = (from x in ctx.LandingPageKeywordXREFs where x.KeywordId == keywordId select x).ToList <LandingPageKeywordXREF>(); if (lxrefs.Count > 0) { foreach (LandingPageKeywordXREF x in lxrefs) { ctx.LandingPageKeywordXREFs.Remove(x); } } ctx.ProjectKeywordXREFs.Remove(pxref); ctx.Keywords.Remove(keyword); ctx.SaveChanges(); } }
public void DeleteLandingPage(int landingPageId) { p1p.Data.LandingPage landingPage; p1p.Data.ProjectLandingPageXREF pxref; List <p1p.Data.LandingPageKeywordXREF> kxrefs; using (P1PContext ctx = new P1PContext()) { landingPage = ctx.LandingPages.Single(l => l.Id == landingPageId); pxref = ctx.ProjectLandingPageXREFs.Single(x => x.LandingPageId == landingPageId); kxrefs = (from x in ctx.LandingPageKeywordXREFs where x.LandingPageId == landingPageId select x).ToList <LandingPageKeywordXREF>(); if (kxrefs.Count > 0) { foreach (LandingPageKeywordXREF x in kxrefs) { ctx.LandingPageKeywordXREFs.Remove(x); } } ctx.ProjectLandingPageXREFs.Remove(pxref); ctx.LandingPages.Remove(landingPage); ctx.SaveChanges(); } }