public async Task <int> SearchRecordCountAsync(ContactSearchRequest rq) { List <ContactModel> allContacts = await ParseContactDataAsync(FilePath); int recordCount = allContacts.Count(c => c.FirstName.Contains(rq.Query) || c.LastName.Contains(rq.Query) || c.Email.Contains(rq.Query) || c.Phone1.Contains(rq.Query)); return(recordCount); }
public async Task <int> SearchRecordCountAsync(ContactSearchRequest rq) { // Create query IQueryable <Contact> query = Db.Contacts .Where(c => c.FirstName.Contains(rq.Query) || c.LastName.Contains(rq.Query) || c.Email.Contains(rq.Query) || c.Phone1.Contains(rq.Query)); // Retrieve data int recordCount = await query.CountAsync(); return(recordCount); }
public async Task <int> SearchRecordCountAsync(ContactSearchRequest rq) { // Load data from csv file string fileData = await FileHandler.LoadFileAsync(); List <ContactModel> allContacts = ParseDataString(fileData); int recordCount = allContacts .Count(c => c.FirstName.Contains(rq.Query) || c.LastName.Contains(rq.Query) || c.Email.Contains(rq.Query) || c.Phone1.Contains(rq.Query)); return(recordCount); }
public async Task <List <ContactModel> > SearchAsync(ContactSearchRequest rq) { List <ContactModel> allContacts = await ParseContactDataAsync(FilePath); List <ContactModel> result = allContacts .Where(c => c.FirstName.Contains(rq.Query) || c.LastName.Contains(rq.Query) || c.Email.Contains(rq.Query) || c.Phone1.Contains(rq.Query)) .Skip(rq.SkipCount) .Take(rq.TakeCount) .ToList(); return(result); }
public Task <int> SearchRecordCountAsync(ContactSearchRequest rq) { return(Task.Run(() => { if (_contacts.Count == 0) { LoadContacts(); } int recordCount = _contacts.Count(c => c.FirstName.Contains(rq.Query) || c.LastName.Contains(rq.Query) || c.Email.Contains(rq.Query) || c.Phone1.Contains(rq.Query)); return recordCount; })); }
public async Task <List <ContactModel> > SearchAsync(ContactSearchRequest rq) { // Load data from csv file string fileData = await FileHandler.LoadFileAsync(); List <ContactModel> allContacts = ParseDataString(fileData); List <ContactModel> result = allContacts .Where(predicate: c => c.FirstName.Contains(rq.Query) || c.LastName.Contains(rq.Query) || c.Email.Contains(rq.Query) || c.Phone1.Contains(rq.Query)) .Skip(rq.SkipCount) .Take(rq.TakeCount) .ToList(); return(result); }
public async Task <List <ContactModel> > SearchAsync(ContactSearchRequest rq) { // Create query IQueryable <Contact> query = Db.Contacts .Where(c => c.FirstName.Contains(rq.Query) || c.LastName.Contains(rq.Query) || c.Email.Contains(rq.Query) || c.Phone1.Contains(rq.Query)) .Skip(rq.SkipCount) .Take(rq.TakeCount); // Retrieve data List <Contact> contacts = await query.ToListAsync(); // Map to model List <ContactModel> dtoList = Mapper.Map <List <ContactModel> >(contacts); return(dtoList); }
public Task <List <ContactModel> > SearchAsync(ContactSearchRequest rq) { return(Task.Run(() => { if (_contacts.Count == 0) { LoadContacts(); } List <ContactModel> result = _contacts .Where(c => c.FirstName.Contains(rq.Query) || c.LastName.Contains(rq.Query) || c.Email.Contains(rq.Query) || c.Phone1.Contains(rq.Query)) .Skip(rq.SkipCount) .Take(rq.TakeCount) .ToList(); return result; })); }