Exemplo n.º 1
0
        public async Task <PagedList <ContactDto> > GetContactsAsync(LimitationParameters limitationParameters)
        {
            var result = await _contactRepository.GetAsync(limitationParameters);

            var paginatedList = new PagedList <ContactDto>(_mapper.Map <List <ContactDto> >(result.Items), limitationParameters, result.TotalCount);

            return(paginatedList);
        }
Exemplo n.º 2
0
 public async Task <PagedList <ContactDto> > GetContactsAsync(LimitationParameters limitationParameters, string phoneNumber = null, string name = null)
 {
     if (phoneNumber != null)
     {
         return(await GetContactsByPhoneNumberAsync(phoneNumber, limitationParameters));
     }
     else if (name != null)
     {
         return(await GetContactsByNameAsync(name, limitationParameters));
     }
     return(await GetContactsAsync(limitationParameters));
 }
Exemplo n.º 3
0
        public async Task <SelectResult <Contact> > GetAsync(LimitationParameters limitationParameters)
        {
            try
            {
                await _sqlConnection.OpenAsync();

                return(await SelectAllContactsAsync(_sqlConnection, _mapper, limitationParameters));
            }
            finally
            {
                _sqlConnection.Close();
            }
        }
Exemplo n.º 4
0
        public async Task <SelectResult <Contact> > GetByNameAsync(string name, LimitationParameters limitationParameters)
        {
            try
            {
                await _sqlConnection.OpenAsync();

                return(await SelectNameContactsAsync(_sqlConnection, _mapper, name, limitationParameters));
            }
            finally
            {
                _sqlConnection.Close();
            }
        }
Exemplo n.º 5
0
        public PagedList(IEnumerable <T> source, LimitationParameters limitationParameters, int totalCount)
        {
            PageIndex = limitationParameters.PageIndex;

            TotalCount = totalCount;
            TotalPages = TotalCount / limitationParameters.PageSize;

            if (TotalCount % limitationParameters.PageSize > 0)
            {
                TotalPages++;
            }

            PageSize = limitationParameters.PageSize;

            Items = new List <T>(source);
        }
Exemplo n.º 6
0
        public async Task <SelectResult <Contact> > GetByPhoneNumberAsync(string phoneNumber, LimitationParameters limitationParameters)
        {
            try
            {
                await _sqlConnection.OpenAsync();

                return(await SelectPhoneContactsAsync(_sqlConnection, _mapper, phoneNumber, limitationParameters));
            }
            finally
            {
                _sqlConnection.Close();
            }
        }