コード例 #1
0
        public async Task <Response <IEnumerable <GetAllProductsViewModel> > > Handle(GetAllProductsQuery request, CancellationToken cancellationToken)
        {
            var validFilter = _mapper.Map <GetAllProductsParameter>(request);
            var product     = await _productRepository.GetAllAsync();

            var productViewModel = _mapper.Map <IEnumerable <GetAllProductsViewModel> >(product);

            return(new Response <IEnumerable <GetAllProductsViewModel> >(productViewModel));
        }
        public async Task <bool> IsUniqueBarcode(string barcode, CancellationToken cancellationToken)
        {
            // TODO Check performance here
            var products = await productRepository.GetAllAsync();

            if (products.Count == 0)
            {
                return(true);
            }
            var unique = products.Where(a => a.Barcode == barcode).ToList();

            if (unique.Count > 0)
            {
                return(false);
            }
            return(true);
        }