Exemplo n.º 1
0
        public void AddProduct(DTOs.Product product, DTOs.ProductDetails productDetails)
        {
            using (APShopContext context = new APShopContext())
            {
                UnitOfWork                  UoW              = new UnitOfWork(context);
                EntityModels.Product        EMProduct        = _mapper.Map <EntityModels.Product>(product);
                EntityModels.ProductDetails EMProductDetails = _mapper.Map <EntityModels.ProductDetails>(productDetails);

                UoW.Product.AddProduct(EMProduct);
                EMProduct.ProductDetails.Add(EMProductDetails);

                UoW.commit();
            }
        }
Exemplo n.º 2
0
        public bool UpdateProduct(DTOs.Product product, DTOs.ProductDetails productDetails)
        {
            using (APShopContext context = new APShopContext())
            {
                UnitOfWork                  UoW              = new UnitOfWork(context);
                EntityModels.Product        EMProduct        = _mapper.Map <EntityModels.Product>(product);
                EntityModels.ProductDetails EMProductDetails = _mapper.Map <EntityModels.ProductDetails>(productDetails);

                var Exists = UoW.Product.GetByCode(product.Code);

                if (Exists != null)
                {
                    Exists.IsActive = false;
                    UoW.Product.AddProduct(EMProduct);
                    EMProduct.ProductDetails.Add(EMProductDetails);
                    UoW.commit();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }