public Task <CountryDto> GetCountry(int id) { var country = _readOnlyService.Repository <Country>().Get(i => i.AutoId == id).FirstOrDefault(); var countryDto = LocationMapper.EntityToDto(country); var provinces = _readOnlyService.Repository <Province>().Get(i => i.CountryId == id).ToList(); countryDto.Provinces = LocationMapper.EntityToDtos(provinces).ToList(); return(Task.FromResult(countryDto)); }
public Task <PagedResult <CountryDto> > GetPaged(string name, string orderBy = "", bool orderAsc = true, int page = 1, int pageSize = 20) { var data = _readOnlyService.Repository <Country>().GetPaged(i => string.IsNullOrEmpty(name) || i.Name.ToLower().Contains(name.ToLower()), page: page, pageSize: pageSize); var result = new PagedResult <CountryDto> { CurrentPage = data.CurrentPage, PageCount = data.PageCount, PageSize = data.PageSize, RowCount = data.RowCount, Results = LocationMapper.EntityToDtos(data.Results) }; return(Task.FromResult(result)); }
public Task <IEnumerable <CountryDto> > GetCountries() { return(Task.FromResult(LocationMapper.EntityToDtos(_readOnlyService.Repository <Country>().Get(i => !i.Deleted).ToList()))); }