public PagingResultDto <IEnumerable <ProductDto> > GetAllProduct(ProductFilterRequestDto request, int RequestUserId, string TokenKey)
 {
     try
     {
         CheckAuthentication(RequestUserId, TokenKey);
         var data      = GetAllCachedData <ProductEntity>().AsQueryable();
         var predicate = PredicateBuilderHelper.True <ProductEntity>();
         if (request.PriceStart.HasValue && request.PriceEnd.HasValue)
         {
             predicate = predicate.And(q => q.Price >= request.PriceStart && q.Price <= request.PriceEnd);
         }
         if (request.DiscountPriceStart.HasValue && request.DiscountPriceEnd.HasValue)
         {
             predicate = predicate.And(q => q.DiscountPrice >= request.DiscountPriceStart && q.DiscountPrice <= request.DiscountPriceEnd);
         }
         if (request.ProductTypeId.HasValue)
         {
             predicate = predicate.And(q => q.ProductTypeId == request.ProductTypeId.Value);
         }
         var result     = data.Where(predicate).AsEnumerable();
         var rdata      = result.ConvertTo <IEnumerable <ProductDto> >();
         var ReturnData = PageingHelper.GetPagingResult(rdata, request.PageNumber, request.PageSize);
         return(ReturnData);
     }
     catch (KnownException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         Logger.AddLog(LogTypeEnum.Error, "ProductManager.GetAllProduct", RequestUserId, ex.Message, request.ToJson(), ex);
         throw new KnownException(ErrorTypeEnum.UnexpectedExeption, ex.Message, ex);
     }
 }
Пример #2
0
 public PagingResultDto <IEnumerable <UsersDto> > GetAll(UserFilterRequestDto request, int RequestUserId, string TokenKey)
 {
     try
     {
         CheckAuthentication(RequestUserId, TokenKey);
         var data      = GetAllCachedData <UsersDto>().AsQueryable();
         var predicate = PredicateBuilderHelper.True <UsersDto>();
         if (request.Id.HasValue)
         {
             predicate = predicate.And(q => q.Id == request.Id);
         }
         if (request.ActivationStatus.HasValue)
         {
             predicate = predicate.And(q => q.ActivationStatus == request.ActivationStatus);
         }
         if (!request.UserName.IsNullOrEmpty())
         {
             predicate = predicate.And(q => q.UserName.Contains(request.UserName));
         }
         if (!request.FullName.IsNullOrEmpty())
         {
             predicate = predicate.And(q => q.FullName.Contains(request.FullName));
         }
         if (!request.EMail.IsNullOrEmpty())
         {
             predicate = predicate.And(q => q.EMail == request.EMail);
         }
         var result     = data.Where(predicate).AsEnumerable();
         var ReturnData = PageingHelper.GetPagingResult(result, request.PageNumber, request.PageSize);
         return(ReturnData);
     }
     catch (KnownException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         Logger.AddLog(LogTypeEnum.Error, "UserManager.GetAll", RequestUserId, ex.Message, request.ToJson(), ex);
         throw new KnownException(ErrorTypeEnum.UnexpectedExeption, ex.Message, ex);
     }
 }