public async Task <BaseResponse <IEnumerable <AreaGroupResponse> > > List(AreaGroupListRequest model)
        {
            IEnumerable <AreaGroup> areaList = await _db.AreaGroups.Where(
                x => (string.IsNullOrEmpty(model.GroupName) || x.GroupName.Contains(model.GroupName))
                ).ToListAsync();

            int totalCount = areaList.Count();

            var result = areaList.Skip((model.PageNumber - 1) * model.PageSize).Take(model.PageSize);
            IEnumerable <AreaGroupResponse> response = _mapper.Map <IEnumerable <AreaGroupResponse> >(result);


            if (response != null)
            {
                return(new BaseResponse <IEnumerable <AreaGroupResponse> >
                {
                    Code = RsponseCode.Success,
                    Message = "",
                    Data = response,
                    TotalCount = totalCount
                });
            }


            return(new BaseResponse <IEnumerable <AreaGroupResponse> >
            {
                Code = RsponseCode.NotFound,
                Message = "لا يوجد بيانات ",
                Data = null
            });
        }
Example #2
0
        public async Task <IActionResult> List([FromBody] AreaGroupListRequest model)
        {
            var result = await _areaGroupService.List(model);

            return(Ok(result));
        }