예제 #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);
        }
예제 #5
0
 public void Update(Product product)
 {
     _context.Entry<Product>(product).State = System.Data.Entity.EntityState.Modified;
 }
예제 #6
0
 public void Delete(Product product)
 {
     _context.Products.Remove(product);
 }
예제 #7
0
 public void Create(Product product)
 {
     _context.Products.Add(product);
 }