Exemple #1
0
 public TeamDTO GetTeamByName(string name)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((TeamDTO)P1PObjectMapper.Convert(ctx.Teams.Single(t => t.Name.Equals(name)), typeof(TeamDTO)));
     }
 }
Exemple #2
0
 public EmployeeDTO Get(int id)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((EmployeeDTO)P1PObjectMapper.Convert(ctx.Employees.Single(a => a.Id == id), typeof(EmployeeDTO)));
     }
 }
Exemple #3
0
 public PersonaDTO GetById(int Id)
 {
     using (p1p.Data.P1PContext ctx = new Data.P1PContext())
     {
         return((PersonaDTO)P1PObjectMapper.Convert(ctx.Personas.Single(p => p.Id == Id), typeof(PersonaDTO)));
     }
 }
        public LinkDTO UpdateLink(LinkDTO link, string userName)
        {
            p1p.Data.Link mdlLink = (p1p.Data.Link)P1PObjectMapper.Convert(link, typeof(p1p.Data.Link));
            p1p.Data.Link match;
            mdlLink.LastModifiedBy   = userName;
            mdlLink.DateLastModified = DateTime.Now;

            using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
            {
                match = ctx.Links.Single(l => link.Id == l.Id);
                if (match.LinkStatusId != 10 && link.LinkStatus.Id == 10)
                {
                    throw new Exception("You cannot set a link active through the 'UpdateLink' method.");
                }

                if (match.LinkStatusId != 14 && link.LinkStatus.Id == 14)
                {
                    throw new Exception("You cannot set a link to 'Request Active' through the 'UpdateLink' method.");
                }

                if (link.Article != null && link.Article.Id > 0)
                {
                    p1p.Data.ProjectArticleXREF pax = ctx.ProjectArticleXREFs.Single(x => x.ArticleId == link.Article.Id && x.ProjectId == link.ProjectId);
                    mdlLink.ProjectArticleXREFId = pax.Id;
                }

                ctx.Entry(match).CurrentValues.SetValues(mdlLink);
                ctx.SaveChanges();
                return((LinkDTO)P1PObjectMapper.Convert(match, typeof(LinkDTO)));
            }
        }
        public LinkDTO RequestActive(LinkDTO link, string userName)
        {
            p1p.Data.Link mdlLink = (p1p.Data.Link)P1PObjectMapper.Convert(link, typeof(p1p.Data.Link));
            p1p.Data.Link match;
            mdlLink.LastModifiedBy   = userName;
            mdlLink.DateLastModified = DateTime.Now;

            using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
            {
                match = ctx.Links.Single(l => link.Id == l.Id);

                if (link.Article != null && link.Article.Id > 0)
                {
                    p1p.Data.ProjectArticleXREF pax = ctx.ProjectArticleXREFs.Single(x => x.ArticleId == link.Article.Id && x.ProjectId == link.ProjectId);
                    mdlLink.ProjectArticleXREFId = pax.Id;
                }

                mdlLink.LinkStatusId  = 14;
                mdlLink.AcquiredBy    = userName;
                mdlLink.DatePublished = DateTime.Now;

                ctx.Entry(match).CurrentValues.SetValues(mdlLink);
                ctx.SaveChanges();
                return((LinkDTO)P1PObjectMapper.Convert(match, typeof(LinkDTO)));
            }
        }
 public LinkDTO Get(int linkId)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((LinkDTO)P1PObjectMapper.Convert(ctx.Links.Single(l => l.Id == linkId), typeof(LinkDTO)));
     }
 }
        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();
            }
        }
Exemple #8
0
 public EmployeeDTO GetByUser(string User)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((EmployeeDTO)P1PObjectMapper.Convert(ctx.Employees.Single(e => e.Username.Equals(User)), typeof(EmployeeDTO)));
     }
 }
 public ProjectDTO GetProject(int id)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((ProjectDTO)P1PObjectMapper.Convert(ctx.Projects.Single(p => p.Id == id), typeof(ProjectDTO)));
     }
 }
 public ProjectDTO GetProjectByName(string name)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((ProjectDTO)P1PObjectMapper.Convert(ctx.Projects.Single(p => p.Name.Equals(name)), typeof(ProjectDTO)));
     }
 }
Exemple #11
0
 public TeamDTO Get(int id)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((TeamDTO)P1PObjectMapper.Convert(ctx.Teams.Single(t => t.Id == id), typeof(TeamDTO)));
     }
 }
Exemple #12
0
 public CustomerDTO GetCustomerByUser(string user)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((CustomerDTO)P1PObjectMapper.Convert(ctx.Customers.Single(c => c.Username.Equals(user)), typeof(CustomerDTO)));
     }
 }
Exemple #13
0
 public void AddOutreach(OutreachDTO entry, string user)
 {
     p1p.Data.Link link;
     p1p.Data.Link linkMatch;
     entry.AddedBy    = user;
     entry.InsertDate = DateTime.Now;
     p1p.Data.Outreach mdlOutreach = (p1p.Data.Outreach)P1PObjectMapper.Convert(entry, typeof(p1p.Data.Outreach));
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         if (entry.OutreachAction != null && ctx.OutreachActions.FirstOrDefault(oa => oa.Id == entry.OutreachAction.Id) != null)
         {
             linkMatch             = ctx.Links.Single(l => entry.LinkId == l.Id);
             link                  = linkMatch;
             link.LastModifiedBy   = user;
             link.DateLastModified = DateTime.Now;
             ctx.Outreaches.Add(mdlOutreach);
             ctx.Entry(linkMatch).CurrentValues.SetValues(link);
             ctx.SaveChanges();
         }
         else
         {
             throw new Exception("You must select an outreach action to save this outreach.");
         }
     }
 }
Exemple #14
0
 public CustomerDTO Get(int id)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((CustomerDTO)P1PObjectMapper.Convert(ctx.Customers.Single(a => a.Id == id), typeof(CustomerDTO)));
     }
 }
 public List <LandingPageDTO> GetLandingPagesForProject(int projectId)
 {
     using (P1PContext ctx = new P1PContext()) {
         return((from x in ctx.ProjectLandingPageXREFs where x.ProjectId == projectId select x.LandingPage)
                .AsEnumerable()
                .Select(l => (LandingPageDTO)P1PObjectMapper.Convert(l, typeof(LandingPageDTO))).ToList <LandingPageDTO>());
     }
 }
 public List <KeyValueDTO> GetArticleStatuses()
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from s in ctx.ArticleStatuses select s)
                .AsEnumerable()
                .Select(s => (KeyValueDTO)P1PObjectMapper.Convert(s, typeof(KeyValueDTO))).ToList <KeyValueDTO>());
     }
 }
 public List <KeywordDTO> GetKeywordsForLandingPage(int landingPageId)
 {
     using (P1PContext ctx = new P1PContext())
     {
         return((from x in ctx.LandingPageKeywordXREFs where x.LandingPageId == landingPageId select x.Keyword)
                .AsEnumerable()
                .Select(k => (KeywordDTO)P1PObjectMapper.Convert(k, typeof(KeywordDTO))).ToList <KeywordDTO>());
     }
 }
 public List <SocialAccountDTO> GetSocialAccountsForPersona(int personaId)
 {
     using (P1PContext ctx = new P1PContext())
     {
         return((from x in ctx.PersonaSocialAccountXREFs where x.PersonaId == personaId select x.SocialAccount)
                .AsEnumerable()
                .Select(s => (SocialAccountDTO)P1PObjectMapper.Convert(s, typeof(SocialAccountDTO))).ToList <SocialAccountDTO>());
     }
 }
 public List <ProjectDTO> GetAllActive()
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from p in ctx.Projects where p.IsActive orderby p.Name select p)
                .AsEnumerable()
                .Select(p => (ProjectDTO)P1PObjectMapper.Convert(p, typeof(ProjectDTO))).ToList <ProjectDTO>());
     }
 }
 public List <PersonaDTO> GetPersonasForProject(int projectId)
 {
     using (P1PContext ctx = new P1PContext())
     {
         return((from x in ctx.ProjectPersonaXREFs where x.ProjectId == projectId select x.Persona)
                .AsEnumerable()
                .Select(p => (PersonaDTO)P1PObjectMapper.Convert(p, typeof(PersonaDTO))).ToList <PersonaDTO>());
     }
 }
 public List <ProjectDTO> GetProjectsForAccount(int accountId)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from p in ctx.Projects where p.CustomerId == accountId orderby p.Name select p)
                .AsEnumerable()
                .Select(p => (ProjectDTO)P1PObjectMapper.Convert(p, typeof(ProjectDTO))).ToList <ProjectDTO>());
     }
 }
Exemple #22
0
 public List <EmployeeDTO> GetAll()
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from e in ctx.Employees select e)
                .AsEnumerable()
                .Select(e => (EmployeeDTO)P1PObjectMapper.Convert(e, typeof(EmployeeDTO))).ToList <EmployeeDTO>());
     }
 }
Exemple #23
0
 public List <CustomerDTO> SearchCustomers()
 {
     using (p1p.Data.P1PContext ctx = new Data.P1PContext())
     {
         return((from c in ctx.Customers select c)
                .AsEnumerable()
                .Select(c => (CustomerDTO)P1PObjectMapper.Convert(c, typeof(CustomerDTO))).ToList <CustomerDTO>());
     }
 }
Exemple #24
0
 public List <CustomerDTO> GetAll()
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from c in ctx.Customers orderby c.BusinessName select c)
                .AsEnumerable()
                .Select(c => (CustomerDTO)P1PObjectMapper.Convert(c, typeof(CustomerDTO))).ToList <CustomerDTO>());
     }
 }
 public List <ProjectDTO> GetProjectsForTeam(int teamId)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from o in ctx.OrderTeamXREFs where o.TeamId == teamId orderby o.Project.Name select o.Project)
                .AsEnumerable()
                .Select(p => (ProjectDTO)P1PObjectMapper.Convert(p, typeof(ProjectDTO))).ToList <ProjectDTO>());
     }
 }
Exemple #26
0
 public List <OutreachDTO> GetAllOutreachForLink(int linkId)
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from o in ctx.Outreaches where o.LinkId == linkId select o)
                .AsEnumerable()
                .Select(o => (OutreachDTO)P1PObjectMapper.Convert(o, typeof(OutreachDTO))).ToList <OutreachDTO>());
     }
 }
Exemple #27
0
 public List <TeamDTO> GetAll()
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from t in ctx.Teams select t)
                .AsEnumerable()
                .Select(t => (TeamDTO)P1PObjectMapper.Convert(t, typeof(TeamDTO))).ToList <TeamDTO>());
     }
 }
        public void UpdateProject(ProjectDTO item)
        {
            p1p.Data.Project mdlProject = (p1p.Data.Project)P1PObjectMapper.Convert(item, typeof(p1p.Data.Project));
            p1p.Data.Project match;
            using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
            {
                match = ctx.Projects.Single(p => item.Id == p.Id);
                if (match.IsActive && !mdlProject.IsActive)
                {
                    List <Link> killLinks = ctx.Links.Where(l => l.ProjectId == item.Id &&
                                                            l.LinkStatusId != 5 &&
                                                            l.LinkStatusId != 8 &&
                                                            l.LinkStatusId != 9 &&
                                                            l.LinkStatusId != 10 &&
                                                            l.LinkStatusId != 11 &&
                                                            l.LinkStatusId != 12).ToList <Link>();
                    foreach (Link link in killLinks)
                    {
                        Link deadLink = link;
                        deadLink.LinkStatusId = 8;
                        ctx.Entry(link).CurrentValues.SetValues(deadLink);
                    }
                    ctx.SaveChanges();
                }

                ctx.Entry(match).CurrentValues.SetValues(mdlProject);
                ctx.SaveChanges();

                List <OrderTeamXREF> matchingxref = ctx.OrderTeamXREFs.Where(x => x.OrderId == item.Id).ToList <OrderTeamXREF>();
                if (matchingxref.Count > 0)
                {
                    DateTime      InsertDate = DateTime.Now;
                    OrderTeamXREF xref       = matchingxref[0];
                    ctx.OrderTeamXREFs.Remove(xref);
                    OrderTeamXREF newxref = new OrderTeamXREF()
                    {
                        TeamId = item.Team.Id, OrderId = item.Id, InsertDate = InsertDate
                    };
                    ctx.OrderTeamXREFs.Add(newxref);
                    ctx.SaveChanges();
                }
                else
                {
                    if (item.Team.Id > 0)
                    {
                        DateTime      InsertDate = DateTime.Now;
                        OrderTeamXREF newxref    = new OrderTeamXREF()
                        {
                            TeamId = item.Team.Id, OrderId = item.Id, InsertDate = InsertDate
                        };
                        ctx.OrderTeamXREFs.Add(newxref);
                        ctx.SaveChanges();
                    }
                }
            }
        }
 public List <KeyValueDTO> GetOutreachTypes()
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from ot in ctx.OutreachTypes
                 select ot)
                .AsEnumerable()
                .Select(ot => (KeyValueDTO)P1PObjectMapper.Convert(ot, typeof(KeyValueDTO))).ToList <KeyValueDTO>());
     }
 }
 public List <KeyValueDTO> GetSiteCategories()
 {
     using (p1p.Data.P1PContext ctx = new p1p.Data.P1PContext())
     {
         return((from sc in ctx.SiteCategories
                 select sc)
                .AsEnumerable()
                .Select(sc => (KeyValueDTO)P1PObjectMapper.Convert(sc, typeof(KeyValueDTO))).ToList <KeyValueDTO>());
     }
 }