Exemple #1
0
        //[Authorize]
        public async Task <IActionResult> ListAdmin([FromBody] FilterCountryModel filter)
        {
            var res = _countryService.FillterModel(filter);

            return(Json(new ResultBase <PagedList <CountryModel> >()
            {
                success = true, data = new PagedList <CountryModel>()
                {
                    list = res.Data, pager = filter.Paging
                }
            }));
        }
Exemple #2
0
        public ActionResultType <List <CountryModel> > FillterModel(FilterCountryModel filter)
        {
            using (var db = _CountryRepository.GetDbContext())
            {
                var q = from o in db.Country
                        select o;
                if (!string.IsNullOrEmpty(filter.Search))
                {
                    //  q = q.Where(c => c.Name.Contains(filter.Search) || c.Code.Contains(filter.Search));
                }
                var list = q.OrderByDescending(c => c.Id).Skip(filter.Paging.StartRowIndex).Take(filter.Paging.PageSize).ToList();
                filter.Paging.RowsCount = q.Count();
                var listModels = list.CloneToListModels <Country, CountryModel>();

                return(new ActionResultType <List <CountryModel> >()
                {
                    Success = true, Data = listModels
                });
            }
        }