public async Task <int> ListPageCountAsync(ContactListRequest rq)
        {
            List <ContactModel> allContacts = await ParseContactDataAsync(FilePath);

            int recordCount = allContacts.Count();

            return((recordCount + rq.RowsPerPage - 1) / rq.RowsPerPage);
        }
        public async Task <List <ContactModel> > ListAsync(ContactListRequest rq)
        {
            List <ContactModel> allContacts = await ParseContactDataAsync(FilePath);

            List <ContactModel> result = allContacts
                                         .Skip(rq.SkipCount)
                                         .Take(rq.TakeCount)
                                         .ToList();

            return(result);
        }
示例#3
0
        public async Task <List <ContactModel> > ListAsync(ContactListRequest rq)
        {
            // Create query
            IQueryable <Contact> query = _db.Contacts
                                         .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> > ListAsync(ContactListRequest rq)
        {
            // Load data from csv file
            string fileData = await FileHandler.LoadFileAsync();

            List <ContactModel> allContacts = ParseDataString(fileData);

            List <ContactModel> result = allContacts
                                         .Skip(rq.SkipCount)
                                         .Take(rq.TakeCount)
                                         .ToList();

            return(result);
        }
示例#5
0
        public Task<List<ContactModel>> ListAsync(ContactListRequest rq)
        {
            return Task.Run(() =>
            {
                if (_contacts.Count == 0)
                    LoadContacts();

                List<ContactModel> result = _contacts
                    .Skip(rq.SkipCount)
                    .Take(rq.TakeCount)
                    .ToList();

                return result;
            });
        }