示例#1
0
        public void TestMethod1()
        {
            var category = new Category("Placa Mãe");
            var product = new Product();

            category.Title = "";

            // Salvar Categoria
        }
示例#2
0
 public static bool AddProductScopeIsValid(this OrderItem orderItem, Product product, decimal price, int quantity)
 {
     return AssertionConcern.IsSatisfiedBy
     (
         AssertionConcern.AssertIsGreaterOrEqualThan((product.QuantityOnHand - quantity), 0, "Produto fora de estoque: " + product.Title),
         AssertionConcern.AssertIsGreaterThan(price, 0, "Preço deve ser maior que zero"),
         AssertionConcern.AssertIsGreaterThan(quantity, 0, "Quantidade deve ser maior que zero")
     );
 }
        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;
        }
示例#4
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);
        }
 public void Update(Product product)
 {
     _context.Entry<Product>(product).State = System.Data.Entity.EntityState.Modified;
 }
 public void Delete(Product product)
 {
     _context.Products.Remove(product);
 }
 public void Create(Product product)
 {
     _context.Products.Add(product);
 }