Exemplo n.º 1
0
        public void NotifyExpiredProducts()
        {
            var ListEnt = _productRepository.GetExpiredProducts();

            if (!ListEnt.IsNull())
            {
                var response = MappingManagement.GetMappingConfiguration().Map <List <ProductDTO> >(ListEnt);

                _amqpService.PublishMessage(QueueLists.EXPIRED_ITEMS, response);
            }
        }
Exemplo n.º 2
0
        public ProductDTO GetProductById(int id)
        {
            if (id <= 0)
            {
                throw new ArgumentNotValidException(Exceptions.Code.INVALID_OBJECT, Exceptions.Message.INVALID_OBJECT);
            }

            var ent = _productRepository.Get(x => x.Id == id).ToList().FirstOrDefault();

            return(MappingManagement.GetMappingConfiguration().Map <ProductDTO>(ent));
        }
Exemplo n.º 3
0
        public ProductDTO AddProduct(ProductDTO product)
        {
            if (!_productHelper.ValidateProduct(product))
            {
                throw new InvalidObjectException(Exceptions.Code.INVALID_OBJECT, Exceptions.Message.INVALID_OBJECT);
            }

            var ent = MappingManagement.GetMappingConfiguration().Map <Product>(product);

            ent = _productRepository.AddProduct(ent);

            return(MappingManagement.GetMappingConfiguration().Map <ProductDTO>(ent));
        }
Exemplo n.º 4
0
        public ProductDTO DeleteProductById(int id)
        {
            if (id <= 0)
            {
                throw new ArgumentNotValidException(Exceptions.Code.INVALID_OBJECT, Exceptions.Message.INVALID_OBJECT);
            }

            var ent = _productRepository.DeleteProduct(id);

            var response = MappingManagement.GetMappingConfiguration().Map <ProductDTO>(ent);

            _amqpService.PublishMessage(QueueLists.REMOVE_ITEM, response);

            return(response);
        }
Exemplo n.º 5
0
        public ProductDTO GetProductByName(string name)
        {
            if (name.IsNull())
            {
                throw new ArgumentNullException(nameof(name));
            }

            var ent = _productRepository.Get(x => x.Description == name).ToList().FirstOrDefault();

            if (ent.IsNull())
            {
                throw new ArgumentNullException();
            }

            return(MappingManagement.GetMappingConfiguration().Map <ProductDTO>(ent));
        }
Exemplo n.º 6
0
        public List <ProductDTO> GetProducts()
        {
            var ent = _productRepository.Get().ToList();

            return(MappingManagement.GetMappingConfiguration().Map <List <ProductDTO> >(ent));
        }