예제 #1
0
        public IEnumerable <VendingMachineProductPrice> GetByCriteria(VendingMachineProductPriceSearchRequest request)
        {
            var vendingMachineProductPrices = _repository.GetAll();

            if (!string.IsNullOrWhiteSpace(request.ProductCode))
            {
                vendingMachineProductPrices = vendingMachineProductPrices.Where(x => x.Product.Code.ToLower().Contains(request.ProductCode.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(request.ProductName))
            {
                vendingMachineProductPrices = vendingMachineProductPrices.Where(x => x.Product.Name.ToLower().Contains(request.ProductName.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(request.VendingMachineCode))
            {
                vendingMachineProductPrices = vendingMachineProductPrices.Where(x => x.VendingMachine.Code.ToLower().Contains(request.VendingMachineCode.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(request.VendingMachineName))
            {
                vendingMachineProductPrices = vendingMachineProductPrices.Where(x => x.VendingMachine.Name.ToLower().Contains(request.VendingMachineName.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(request.VendingMachineModel))
            {
                vendingMachineProductPrices = vendingMachineProductPrices.Where(x => x.VendingMachine.Model.ToLower().Contains(request.VendingMachineModel.ToLower()));
            }
            return(vendingMachineProductPrices);
        }
예제 #2
0
        public IActionResult GetByCriteria([FromQuery] VendingMachineProductPriceSearchRequest request)
        {
            var vendingMachineProductPrices = _vendingMachineProductPriceService.GetByCriteria(request);

            return(Ok(vendingMachineProductPrices));
        }