public IEnumerable <ProductDto> GetProductsByCategory(Category category)
        {
            TypeCheck.IsNull(category);
            TypeCheck.IsUsableAsId(category.Id);
            var filter = new ProductByCategoryFilter(category.Id);

            return(_repo.Find(filter).Select(i => i.ToDto()));
        }
Exemplo n.º 2
0
        public static Product Create(Category category, Supplier supplier, string name, decimal price, double stock)
        {
            var product = new Product();

            TypeCheck.IsNull(category);
            TypeCheck.IsUsableAsId(category.Id);
            TypeCheck.IsNull(supplier);
            TypeCheck.IsUsableAsId(supplier.Id);
            product.SetCategory(category.Id);
            product.SetName(name);
            product.SetPrice(price);
            product.SetStock(stock);
            product.SetSupplier(supplier.Id);
            return(product);
        }
Exemplo n.º 3
0
        public static Order Create(Customer customer, Employee employee, bool isUrgent, DateTime?shipDate)
        {
            TypeCheck.IsNull(customer);
            TypeCheck.IsNullOrEmpty(customer.Id);
            TypeCheck.IsNull(employee);
            TypeCheck.IsUsableAsId(employee.Id);
            var order = new Order()
            {
                CustomerId = customer.Id, EmployeeId = employee.Id
            };

            if (isUrgent)
            {
                order.SetAsUrgent(shipDate);
            }
            return(order);
        }
        public static OrderDetail Create(Product product, Order order, double price, double quantity, double discount = 0)
        {
            var orderDetail = new OrderDetail();

            TypeCheck.IsNull(product);
            TypeCheck.IsUsableAsId(product.Id);
            TypeCheck.IsNull(product);
            TypeCheck.IsUsableAsId(order.Id);
            OrderDetailPolicy.CheckPrice(price);
            OrderDetailPolicy.CheckQuantity(quantity);
            orderDetail.SetProduct(product.Id);
            orderDetail.SetOrder(order.Id);
            orderDetail.SetPrice(price);
            orderDetail.SetQuantity(quantity);
            if (discount > 0)
            {
                orderDetail.SetDiscount(discount);
            }
            return(orderDetail);
        }