public bool IsEmailRegistered(string emailAddress) { using (p1p.Data.P1PContext ctx = new Data.P1PContext()) { return(ctx.Employees.Where(c => c.Email.Equals(emailAddress)).Count() > 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 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>()); } }
public List <Types.ReportTimeSpan> getAvailableTimeSpans(int projectId) { List <Types.ReportTimeSpan> ts = new List <Types.ReportTimeSpan>(); p1p.Data.Project p; using (p1p.Data.P1PContext ctx = new Data.P1PContext()) { p = ctx.Projects.Include("BillingCycle").Single(prj => prj.Id == projectId); } DateTime cycleStart; if ("Standard".Equals(p.BillingCycle.Name)) { cycleStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); } else { if (DateTime.Now < new DateTime(DateTime.Now.Year, DateTime.Now.Month, 15)) { cycleStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 15).AddMonths(-1); } else { cycleStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 15); } } ts.Add(new Types.ReportTimeSpan() { Name = "Current Cycle", StartDate = cycleStart, EndDate = cycleStart.AddMonths(1).AddMinutes(-1) }); ts.Add(new Types.ReportTimeSpan() { Name = "Previous Cycle", StartDate = cycleStart.AddMonths(-1), EndDate = cycleStart.AddMinutes(-1) }); ts.Add(new Types.ReportTimeSpan() { Name = "3 Months", StartDate = cycleStart.AddMonths(-2), EndDate = cycleStart.AddMonths(1) }); ts.Add(new Types.ReportTimeSpan() { Name = "6 Months", StartDate = cycleStart.AddMonths(-5), EndDate = cycleStart.AddMonths(1) }); ts.Add(new Types.ReportTimeSpan() { Name = "1 Year", StartDate = cycleStart.AddMonths(-11), EndDate = cycleStart.AddMonths(1) }); //ts.Add(new Types.ReportTimeSpan() { Name = "All Time", StartDate = p.DateCreated, EndDate = DateTime.Now }); return(ts); }
private List <TimeEntryDTO> getPeriodHours(int projectId, Nullable <DateTime> startDate, Nullable <DateTime> endDate) { using (p1p.Data.P1PContext ctx = new Data.P1PContext()) { return((from hr in ctx.TimeEntries where hr.ProjectId == projectId && hr.StartTime >= startDate && hr.EndTime <= endDate select hr) .AsEnumerable() .Select(hr => (TimeEntryDTO)P1PObjectMapper.Convert(hr, typeof(TimeEntryDTO))).ToList <TimeEntryDTO>()); } }
private List <LinkDTO> getPeriodLinks(int projectId, Nullable <DateTime> startDate, Nullable <DateTime> endDate) { using (p1p.Data.P1PContext ctx = new Data.P1PContext()) { return((from lnk in ctx.Links where lnk.ProjectId == projectId && lnk.DateFound >= startDate && lnk.DateFound <= endDate select lnk) .AsEnumerable() .Select(lnk => (LinkDTO)P1PObjectMapper.Convert(lnk, typeof(LinkDTO))).ToList <LinkDTO>()); } }
private List <OutreachDTO> getPeriodOutreach(int projectId, Nullable <DateTime> startDate, Nullable <DateTime> endDate) { using (p1p.Data.P1PContext ctx = new Data.P1PContext()) { var links = ctx.Links.Where(l => l.ProjectId == projectId); return((from l in links join outreach in ctx.Outreaches on l.Id equals outreach.LinkId where outreach.DateOutreached >= startDate && outreach.DateOutreached <= endDate select outreach) .AsEnumerable() .Select(outreach => (OutreachDTO)P1PObjectMapper.Convert(outreach, typeof(OutreachDTO))).ToList <OutreachDTO>()); } }
private List <LinkDTO> getPeriodActiveLinks(int projectId, Nullable <DateTime> startDate, Nullable <DateTime> endDate) { using (p1p.Data.P1PContext ctx = new Data.P1PContext()) { return((from lnk in ctx.Links where lnk.ProjectId == projectId && lnk.DatePublished >= startDate && lnk.DatePublished <= endDate && lnk.LinkStatus.Name.Equals("Link Acquired") select lnk) .AsEnumerable() .Select(lnk => (LinkDTO)P1PObjectMapper.Convert(lnk, typeof(LinkDTO))).ToList <LinkDTO>()); } }
public string GetUsernameByEmail(string emailAddress) { using (p1p.Data.P1PContext ctx = new Data.P1PContext()) { string userName = null; p1p.Data.Customer c = ctx.Customers.FirstOrDefault(cst => cst.Email.Equals(emailAddress)); p1p.Data.Employee e = ctx.Employees.FirstOrDefault(emp => emp.Email.Equals(emailAddress)); if (c != null) { userName = c.Username; } else if (e != null) { userName = e.Username; } return(userName); } }