public object Login_Validation(string Mobile_Email, string Password) { long result; bool ifmobile = long.TryParse(Mobile_Email, out result); Predicate <Volunteer> mob_vol = x => (x.Mobile_Number == Mobile_Email || x.Mobile_Alternate == Mobile_Email) && x.Password == Password; Predicate <Volunteer> email_vol = x => x.Email == Mobile_Email && x.Password == Password; Predicate <User> mob_user = x => (x.Mobile_Number == Mobile_Email || x.Mobile_Alternate == Mobile_Email) && x.Password == Password; Predicate <User> email_user = x => x.Email == Mobile_Email && x.Password == Password; Predicate <Driver> mob_dri = x => (x.Mobile_Number == Mobile_Email || x.Mobile_Alternate == Mobile_Email) && x.Password == Password; Predicate <Driver> email_dri = x => x.Email == Mobile_Email && x.Password == Password; if (ifmobile) { if (Volunteers.Exists(mob_vol)) { return(Volunteers.Where(x => mob_vol(x)).FirstOrDefault()); } else if (Users.Exists(mob_user)) { return(Users.Where(x => mob_user(x)).FirstOrDefault()); } else if (Drivers.Exists(mob_dri)) { return(Drivers.Where(x => mob_dri(x)).FirstOrDefault()); } else { return(null); } } else { if (Volunteers.Exists(email_vol)) { return(Volunteers.Where(x => email_vol(x)).FirstOrDefault()); } else if (Users.Exists(email_user)) { return(Users.Where(x => email_user(x)).FirstOrDefault()); } else if (Drivers.Exists(email_dri)) { return(Drivers.Where(x => email_dri(x)).FirstOrDefault()); } else { return(null); } } }
public async Task <IPagedResults <Volunteer> > GetVolunteersAsync(VolunteersSearchQueryParameters searchQuery) { var onlyEssUsers = searchQuery.OnlyEssUsers ?? false; var onlyAdmins = searchQuery.OnlyAdminUsers ?? false; var items = await Volunteers .Where(v => !searchQuery.HasQuery() || EF.Functions.Like(v.LastName, $"%{searchQuery.Query}%")) .Where(v => !onlyEssUsers || !v.IsAdministrator.Value) .Where(v => !onlyAdmins || v.IsAdministrator.Value) .Where(v => searchQuery.OrganizationId == null || v.Organization.Id == Guid.Parse(searchQuery.OrganizationId)) .Where(t => searchQuery.Active == t.Active) .Sort(searchQuery.SortBy ?? "lastname") .ToArrayAsync(); return(new PaginatedList <Volunteer>(mapper.Map <IEnumerable <Volunteer> >(items), searchQuery.Offset, searchQuery.Limit)); }
public async Task <IPagedResults <Organization> > GetOrganizationsAsync(SearchQueryParameters searchQuery) { Guid? communityId = null; string regionName = null; if (searchQuery.HasQuery() && Guid.TryParse(searchQuery.Query, out Guid searchEntityId)) { communityId = searchEntityId; } else if (searchQuery.HasQuery()) { regionName = searchQuery.Query; } var items = await Organizations .Where(o => (!communityId.HasValue || o.Community.Id == communityId) && (string.IsNullOrEmpty(regionName) || o.RegionName == regionName) ) .Where(t => searchQuery.Active == t.Active) .Sort(searchQuery.SortBy ?? "id") .Join(Volunteers.Where(v => v.IsPrimaryContact ?? false), o => o.Id, pc => pc.Organization.Id, (org, pc) => new { org, pc }) //Assume a single primary contact .ToArrayAsync(); return(new PaginatedList <Organization>(items.Select(i => MapToViewModel(i.org, i.pc)), searchQuery.Offset, searchQuery.Limit)); }
private IQueryable <Models.Db.Volunteer> GetVolunteersByOrganizationId(Guid orgId) { return(Volunteers.Where(v => v.Organization.Id == orgId || v.OrganizationId == orgId)); }