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);
        }
Ejemplo n.º 2
0
        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 <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 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);
        }
Ejemplo n.º 5
0
        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;
            });
        }
Ejemplo n.º 6
0
        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 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);
        }
Ejemplo n.º 8
0
        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;
            });
        }