public async Task <BaseResponse <IEnumerable <AreaResponse> > > List(AreaListRequest model) { IEnumerable <Area> areaList = await _db.Areas .Where(x => (string.IsNullOrEmpty(model.AreaName) || x.AreaName.Contains(model.AreaName)) && (!model.AreaGroupId.HasValue || x.AreaGroupId == model.AreaGroupId) && (!model.CityId.HasValue || x.CityId == model.CityId) && (!model.DriverPrice.HasValue || x.DriverPrice == model.DriverPrice) ) .Include(x => x.City).Include(x => x.AreaGroup).ToListAsync(); int totalCount = areaList.Count(); var result = areaList.Skip((model.PageNumber - 1) * model.PageSize).Take(model.PageSize).Select(x => new AreaResponse { Id = x.Id, AreaGroupId = x.AreaGroupId, AreaGroupName = x.AreaGroup.GroupName, AreaName = x.AreaName, AreaGuid = x.AreaGuid, CityId = x.CityId, DriverPrice = x.DriverPrice, CityName = x.City.CityName }).ToList(); if (result != null) { return(new BaseResponse <IEnumerable <AreaResponse> > { Code = RsponseCode.Success, Message = "", Data = result, TotalCount = totalCount }); } return(new BaseResponse <IEnumerable <AreaResponse> > { Code = RsponseCode.NotFound, Message = "لا يوجد بيانات ", Data = null }); }
public async Task <IActionResult> List([FromBody] AreaListRequest model) { var result = await _areaService.List(model); return(Ok(result)); }