コード例 #1
0
        public Product Create(CreateProductCommand command)
        {
            var product = new Product(command.Title, command.Description, command.Price, command.QuantityOnHand, command.CategoryId);
            product.Register();
            _repository.Create(product);

            if (Commit())
                return product;

            return null;
        }
コード例 #2
0
        public void AddProduct(Product product, int quantity, decimal price)
        {
            if (!this.AddProductScopeIsValid(product, price, quantity))
                return;

            this.ProductId = product.Id;
            this.Product = product;
            this.Quantity = quantity;
            this.Price = price;

            // Reserva o estoque
            this.Product.UpdateQuantityOnHand(this.Product.QuantityOnHand - quantity);
        }
コード例 #3
0
 public void Update(Product product)
 {
     _context.Entry<Product>(product).State = System.Data.Entity.EntityState.Modified;
 }
コード例 #4
0
 public void Delete(Product product)
 {
     _context.Products.Remove(product);
 }
コード例 #5
0
 public void Create(Product product)
 {
     _context.Products.Add(product);
 }