public async Task <IEnumerable <Model.Response.MemberLL> > Get(Model.Search.Member search = null) { var query = _context.Members.Include(x => x.LocalCommittee).Include(x => x.FunctionalField).AsQueryable(); if (!string.IsNullOrWhiteSpace(search?.Username)) { query = query.Where(x => x.Username == search.Username); } if (!string.IsNullOrWhiteSpace(search?.FirstName)) { query = query.Where(x => x.FirstName.ToLower().StartsWith(search.FirstName.ToLower())); } if (!string.IsNullOrWhiteSpace(search?.Email)) { query = query.Where(x => x.EmailAddress == search.Email); } if (!string.IsNullOrWhiteSpace(search?.LastName)) { query = query.Where(x => x.LastName.ToLower().StartsWith(search.LastName.ToLower())); } if (search?.onlyActive != null && search.onlyActive == true) { query = query.Where(x => x.Active == search.onlyActive); } if (!string.IsNullOrWhiteSpace(search?.FunctionalFieldId.ToString()) && search?.FunctionalFieldId != 0) { query = query.Where(x => x.FunctionalFieldId == search.FunctionalFieldId); } if (!string.IsNullOrWhiteSpace(search?.LocalCommitteeId.ToString()) && search?.LocalCommitteeId != 0) { query = query.Where(x => x.LocalCommitteeId == search.LocalCommitteeId); } //if (search?.IncludeList != null) //{ // foreach (string item in search?.IncludeList) // { // query.Include(item); // } //} var entities = await query.Include(x => x.Role).ToListAsync(); var result = _mapper.Map <IList <Model.Response.MemberLL> >(entities); return(result); }
private async Task <bool> IsEmailUnique(string mail) { var req = new Model.Search.Member { Email = mail }; var result = await _memberService.Get <List <Model.Response.MemberLL> >(req); if (result.Count > 0) { return(false); } else { return(true); } }
private async void btnSearch_Click(object sender, EventArgs e) { try { var search = new Model.Search.Member() { FirstName = txtFirstName.Text, LastName = txtlastName.Text, FunctionalFieldId = Convert.ToInt32(cmbFunctionalField.SelectedValue), LocalCommitteeId = Convert.ToInt32(cmbLocalCommittee.SelectedValue), onlyActive = chkActiveOnly.Checked }; dgvMembers.DataSource = await _memberService.Get <List <Model.Response.MemberLL> >(search); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <IEnumerable <Model.Response.Member> > Get([FromQuery] Model.Search.Member request) { return(await _service.Get(request)); }
public async System.Threading.Tasks.Task Init() { if (FunctionalFieldsList.Count == 0) { var functionalFieldsList = await _functionalFieldService.Get <List <FunctionalField> >(null); FunctionalFieldsList.Add(new FunctionalField { Id = 0, Name = "" }); foreach (var funcField in functionalFieldsList) { FunctionalFieldsList.Add(funcField); } } if (LocalCommitteesList.Count == 0) { var localCommittees = await _localCommitteeService.Get <List <LocalCommittee> >(null); LocalCommitteesList.Add(new LocalCommittee { Id = 0, Name = "" }); foreach (var localCommittee in localCommittees) { LocalCommitteesList.Add(localCommittee); } } Model.Search.Member searchMember = new Model.Search.Member(); if (SelectedFunctionalField != null) { searchMember.FunctionalFieldId = SelectedFunctionalField.Id; var list = await _membersService.Get <IEnumerable <Model.Response.MemberLL> >(searchMember); MembersList.Clear(); foreach (var member in list) { MembersList.Add(member); } } if (SelectedLocalCommittee != null) { searchMember.LocalCommitteeId = SelectedLocalCommittee.Id; var list = await _membersService.Get <IEnumerable <Model.Response.MemberLL> >(searchMember); MembersList.Clear(); foreach (var member in list) { MembersList.Add(member); } } if (SelectedFunctionalField == null && SelectedLocalCommittee == null) { var list = await _membersService.Get <IEnumerable <Model.Response.MemberLL> >(null); MembersList.Clear(); foreach (var member in list) { MembersList.Add(member); } } }