public VehicleAnnounceWithPagingSpecification(VehicleAnnounceParams queryParams) : base(x => ( string.IsNullOrEmpty(queryParams.Search) || x.Header.ToLower().Contains(queryParams.Search) || x.Description.ToLower().Contains(queryParams.Search) || x.User.FirstName.ToLower().Contains(queryParams.Search) || x.User.LastName.ToLower().Contains(queryParams.Search) ) && (!queryParams.ScreenId.HasValue || x.VehicleAnnounceSubScreens.Any(y => y.ScreenId == queryParams.ScreenId)) && (!queryParams.SubScreenId.HasValue || x.VehicleAnnounceSubScreens.Any(y => y.SubScreenId == queryParams.SubScreenId)) && (!queryParams.Reject.HasValue || x.Reject == queryParams.Reject) && (!queryParams.IsNew.HasValue || x.IsNew == queryParams.IsNew) && (!queryParams.IsPublish.HasValue || x.IsPublish == queryParams.IsPublish) ) { AddInclude(x => x.VehicleAnnouncePhotos); AddInclude(x => x.VehicleAnnounceSubScreens); AddInclude(x => x.User); AddInclude(x => x.User.Department); AddInclude(x => x.User.Campus); AddInclude(x => x.User.Degree); AddInclude(x => x.VehicleBrand); AddInclude(x => x.VehicleCategory); AddInclude(x => x.VehicleModel); AddInclude(x => x.VehicleFuelType); AddInclude(x => x.VehicleEngineSize); AddInclude(x => x.VehicleGearType); AddOrderByDscending(x => x.IsNew); ApplyPaging(queryParams.PageSize * (queryParams.PageIndex - 1), queryParams.PageSize); }
public VehicleAnnounceByUserIdSpecification(VehicleAnnounceParams queryParams, int userId) : base(x => x.UserId == userId) { AddInclude(x => x.User); AddInclude(x => x.User.Department); AddInclude(x => x.User.Campus); AddInclude(x => x.User.Degree); AddInclude(x => x.VehicleBrand); AddInclude(x => x.VehicleCategory); AddInclude(x => x.VehicleEngineSize); AddInclude(x => x.VehicleFuelType); AddInclude(x => x.VehicleGearType); AddInclude(x => x.VehicleModel); AddInclude(x => x.VehicleAnnouncePhotos); AddOrderByDscending(x => x.Created); ApplyPaging(queryParams.PageSize * (queryParams.PageIndex - 1), queryParams.PageSize); }
public VehicleAnnounceWithFilterForCountSpecification(VehicleAnnounceParams queryParams) : base(x => ( string.IsNullOrEmpty(queryParams.Search) || x.Header.ToLower().Contains(queryParams.Search) || x.Description.ToLower().Contains(queryParams.Search) || x.User.FirstName.ToLower().Contains(queryParams.Search) || x.User.LastName.ToLower().Contains(queryParams.Search) ) && (!queryParams.ScreenId.HasValue || x.VehicleAnnounceSubScreens.Any(y => y.ScreenId == queryParams.ScreenId)) && (!queryParams.SubScreenId.HasValue || x.VehicleAnnounceSubScreens.Any(y => y.SubScreenId == queryParams.SubScreenId)) && (!queryParams.Reject.HasValue || x.Reject == queryParams.Reject) && (!queryParams.IsNew.HasValue || x.IsNew == queryParams.IsNew) && (!queryParams.IsPublish.HasValue || x.IsPublish == queryParams.IsPublish) ) { }
//[SecuredOperation("Sudo,VehicleAnnounces.List,VehicleAnnounces.All", Priority = 1)] public async Task <Pagination <VehicleAnnounceForReturnDto> > GetListAsync(VehicleAnnounceParams queryParams) { var spec = new VehicleAnnounceWithPagingSpecification(queryParams); var listFromRepo = await vehicleAnnounceDal.ListEntityWithSpecAsync(spec); var countSpec = new VehicleAnnounceWithFilterForCountSpecification(queryParams); var totalItem = await vehicleAnnounceDal.CountAsync(countSpec); var data = mapper.Map <List <VehicleAnnounce>, List <VehicleAnnounceForReturnDto> >(listFromRepo); return(new Pagination <VehicleAnnounceForReturnDto> ( queryParams.PageIndex, queryParams.PageSize, totalItem, data )); }
public async Task <Pagination <VehicleAnnounceForUserDto> > GetVehicleAnnounceByUserIdAsync(VehicleAnnounceParams queryParams, int userId) { var claimId = int.Parse(httpContextAccessor.HttpContext.User?.Claims?.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value); if (claimId != userId) { throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.OperationDenied }); } var userFromRepo = await userDal.GetAsync(x => x.Id == userId); if (userFromRepo == null) { throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.UserNotFound }); } var spec = new VehicleAnnounceByUserIdSpecification(queryParams, userId); var vehicleAnnounces = await vehicleAnnounceDal.ListEntityWithSpecAsync(spec); var countSpec = new VehicleAnnounceByUserIdSpecification(userId); var totalItem = await vehicleAnnounceDal.CountAsync(countSpec); var data = mapper.Map <List <VehicleAnnounce>, List <VehicleAnnounceForUserDto> >(vehicleAnnounces); return(new Pagination <VehicleAnnounceForUserDto> ( queryParams.PageIndex, queryParams.PageSize, totalItem, data )); }
public async Task <Pagination <VehicleAnnounceForReturnDto> > List([FromQuery] VehicleAnnounceParams queryParams) { return(await vehicleAnnounceService.GetListAsync(queryParams)); }
public async Task <ActionResult <Pagination <VehicleAnnounceForUserDto> > > VehicleAnnounces([FromQuery] VehicleAnnounceParams queryParams, int userId) { return(await publicAnnounceservice.GetVehicleAnnounceByUserIdAsync(queryParams, userId)); }