public IEnumerable <Person> GetPeople(string filter, int skip, int top, string optin, string group) { using (var context = new Data.PeopleContext()) { IQueryable <Person> people = null; people = context.Person; if (!String.IsNullOrEmpty(filter)) { string[] tags = filter.ToLower().Split(new char[] { ' ' }); people = people.Where(p => tags.All(t => p.Email.ToLower().Contains(t) || p.PersonalId1.Contains(t) || p.PersonalId2.Contains(t) || p.Name.Contains(t))); } people = FilterOptin(people, optin).OrderBy(p => p.Name); if (group != "All" && group != null) { people = people.Where(p => p.GroupName == group); } if (skip != 0) { people = people.Skip(skip); } if (top != 0) { people = people.Take(top); } return(people.ToArray()); } }
public IEnumerable<Person> GetPeople(string filter, int skip, int top, string optin, string group) { using (var context = new Data.PeopleContext()) { IQueryable<Person> people = null; people = context.Person; if (!String.IsNullOrEmpty(filter)) { string[] tags = filter.ToLower().Split(new char[] { ' ' }); people = people.Where(p => tags.All(t => p.Email.ToLower().Contains(t) || p.PersonalId1.Contains(t) || p.PersonalId2.Contains(t) || p.Name.Contains(t))); } people = FilterOptin(people, optin).OrderBy(p => p.Name); if (group != "All" && group != null) people = people.Where(p => p.GroupName == group); if (skip != 0) people = people.Skip(skip); if (top != 0) people = people.Take(top); return people.ToArray(); } }
public bool IsEmailAlreadyRegistred(string email) { using (Data.PeopleContext context = new Data.PeopleContext()) { if (context.Person.Any(p => p.Email == email)) { return(true); } return(false); } }
public IEnumerable<string> GetGroups(int skip, int top) { using (var context = new Data.PeopleContext()) { IQueryable<string> groups = context.Person.Where(p => p.GroupName != null).GroupBy(p => p.GroupName).OrderBy(p => p.FirstOrDefault().GroupName).Select(p => p.FirstOrDefault().GroupName); if (skip != 0) groups = groups.Skip(skip); if (top != 0) groups = groups.Take(top); return groups.ToArray(); } }
public void SavePerson(Person person) { using (Data.PeopleContext context = new Data.PeopleContext()) { Person oldPerson = context.Person.SingleOrDefault(p => p.PersonUId == person.PersonUId); if (oldPerson != null) { context.Person.Attach(oldPerson); context.Entry <Person>(oldPerson).CurrentValues.SetValues(person); } else { context.Person.Add(person); } context.SaveChanges(); } }
public IEnumerable <string> GetGroups(int skip, int top) { using (var context = new Data.PeopleContext()) { IQueryable <string> groups = context.Person.Where(p => p.GroupName != null).GroupBy(p => p.GroupName).OrderBy(p => p.FirstOrDefault().GroupName).Select(p => p.FirstOrDefault().GroupName); if (skip != 0) { groups = groups.Skip(skip); } if (top != 0) { groups = groups.Take(top); } return(groups.ToArray()); } }
public Person GetPersonByEmail(string email) { using (var context = new Data.PeopleContext()) { return(context.Person.Where(p => p.Email == email).SingleOrDefault()); } }
public Person GetPerson(string personUId) { using (Data.PeopleContext context = new Data.PeopleContext()) { return(context.Person.SingleOrDefault(p => p.PersonUId == personUId)); } }
public bool IsEmailAlreadyRegistred(string email) { using (Data.PeopleContext context = new Data.PeopleContext()) { if (context.Person.Any(p => p.Email == email)) return true; return false; } }
public Person GetPersonByEmail(string email) { using (var context = new Data.PeopleContext()) { return context.Person.Where(p => p.Email == email).SingleOrDefault(); } }
public Person GetPerson(string personUId) { using (Data.PeopleContext context = new Data.PeopleContext()) { return context.Person.SingleOrDefault(p => p.PersonUId == personUId); } }
public void SavePerson(Person person) { using (Data.PeopleContext context = new Data.PeopleContext()) { Person oldPerson = context.Person.SingleOrDefault(p => p.PersonUId == person.PersonUId); if (oldPerson != null) { context.Person.Attach(oldPerson); context.Entry<Person>(oldPerson).CurrentValues.SetValues(person); } else context.Person.Add(person); context.SaveChanges(); } }