Beispiel #1
0
        public IActionResult Get(CatCountryCriteria criteria, int page, int size)
        {
            var data   = catCountryService.GetCountries(criteria, page, size, out int rowCount);
            var result = new { data, totalItems = rowCount, page, size };

            return(Ok(result));
        }
        public async Task <IActionResult> ExportCountry(CatCountryCriteria catCountryCriteria)
        {
            Helper helper = new Helper();

            var responseFromApi = await HttpServiceExtension.GetDataFromApi(catCountryCriteria, aPis.CatalogueAPI + Urls.Catelogue.CountryUrl);

            var dataObjects = responseFromApi.Content.ReadAsAsync <List <CatCountry> >();

            var stream = helper.CreateCountryExcelFile(dataObjects.Result);

            return(new FileHelper().ExportExcel(stream, FilesNames.CountryName));
        }
        public IQueryable <CatCountryModel> GetCountries(CatCountryCriteria criteria, int page, int size, out int rowsCount)
        {
            Expression <Func <CatCountryModel, bool> > query = null;

            if (criteria.All == null)
            {
                query = x => (x.Code ?? "").IndexOf(criteria.Code ?? "", StringComparison.OrdinalIgnoreCase) > -1 &&
                        (x.NameEn ?? "").IndexOf(criteria.NameEn ?? "", StringComparison.OrdinalIgnoreCase) > -1 &&
                        (x.NameVn ?? "").IndexOf(criteria.NameVn ?? "", StringComparison.OrdinalIgnoreCase) > -1 &&
                        (x.Active == criteria.Active || criteria.Active == null);
            }
            else
            {
                query = x => ((x.Code ?? "").IndexOf(criteria.All ?? "", StringComparison.OrdinalIgnoreCase) > -1 ||
                              (x.NameEn ?? "").IndexOf(criteria.All ?? "", StringComparison.OrdinalIgnoreCase) > -1 ||
                              (x.NameVn ?? "").IndexOf(criteria.All ?? "", StringComparison.OrdinalIgnoreCase) > -1) &&
                        (x.Active == criteria.Active || criteria.Active == null);
            }
            var data = Paging(query, page, size, x => x.DatetimeModified, false, out rowsCount);

            return(data);
        }
        private IQueryable <CatCountryModel> GetBy(CatCountryCriteria criteria)
        {
            Expression <Func <CatCountryModel, bool> > query = null;

            if (criteria.All == null)
            {
                query = x => (x.Code ?? "").IndexOf(criteria.Code ?? "", StringComparison.OrdinalIgnoreCase) > -1 &&
                        (x.NameEn ?? "").IndexOf(criteria.NameEn ?? "", StringComparison.OrdinalIgnoreCase) > -1 &&
                        (x.NameVn ?? "").IndexOf(criteria.NameVn ?? "", StringComparison.OrdinalIgnoreCase) > -1 &&
                        (x.Active == criteria.Active || criteria.Active == null);
            }
            else
            {
                query = x => ((x.Code ?? "").IndexOf(criteria.All ?? "", StringComparison.OrdinalIgnoreCase) > -1 ||
                              (x.NameEn ?? "").IndexOf(criteria.All ?? "", StringComparison.OrdinalIgnoreCase) > -1 ||
                              (x.NameVn ?? "").IndexOf(criteria.All ?? "", StringComparison.OrdinalIgnoreCase) > -1) &&
                        (x.Active == criteria.Active || criteria.Active == null);
            }
            var data = Get(query);

            return(data);
        }
Beispiel #5
0
        public IActionResult Get(CatCountryCriteria criteria)
        {
            var data = catCountryService.Query(criteria);

            return(Ok(data));
        }
        public IQueryable <CatCountryModel> Query(CatCountryCriteria criteria)
        {
            IQueryable <CatCountryModel> data = GetBy(criteria);

            return(data);
        }