예제 #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)));
     }
 }
예제 #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)));
     }
 }
예제 #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)));
     }
 }
예제 #4
0
        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)));
            }
        }
예제 #5
0
        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)));
            }
        }
예제 #6
0
 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)));
     }
 }
예제 #7
0
        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();
            }
        }
예제 #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)));
     }
 }
예제 #9
0
 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)));
     }
 }
예제 #10
0
 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)));
     }
 }
예제 #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)));
     }
 }
예제 #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)));
     }
 }
예제 #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.");
         }
     }
 }
예제 #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)));
     }
 }
예제 #15
0
 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>());
     }
 }
예제 #17
0
 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>());
     }
 }
예제 #18
0
 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>());
     }
 }
예제 #19
0
 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>());
     }
 }
예제 #20
0
 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>());
     }
 }
예제 #21
0
 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>());
     }
 }
예제 #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>());
     }
 }
예제 #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>());
     }
 }
예제 #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>());
     }
 }
예제 #25
0
 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>());
     }
 }
예제 #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>());
     }
 }
예제 #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>());
     }
 }
예제 #28
0
        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>());
     }
 }