コード例 #1
0
        Order IOrdersCommand.PrepareOrder(IEnumerable <Guid> productIds, Coupon coupon, IEnumerable <Discount> discounts, CreditCardType?creditCardType)
        {
            var order = new Order {
                Items = new List <OrderItem>()
            };

            // Add items for each product.

            var aproductIds = productIds as Guid[] ?? productIds.ToArray();

            foreach (var productId in aproductIds)
            {
                var product = _productsQuery.GetProduct(productId);
                order.Items.Add(new OrderItem {
                    ProductId = productId, Price = product.Price, Currency = product.Currency
                });
            }

            // Set the price.

            _orderPricesCommand.SetOrderPrices(order, aproductIds, coupon, discounts, creditCardType);

            order.Prepare();
            order.Validate();

            return(order);
        }
コード例 #2
0
        public IActionResult Get(Guid id)
        {
            var product = _productsQuery.GetProduct(id);

            if (product == null)
            {
                return(NotFound());
            }

            return(Ok(product));
        }
コード例 #3
0
        public void TestOrder()
        {
            var employer = _employersCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0));

            Assert.AreEqual(0, _orderReportsQuery.GetOrderReports(DayRange.Today).Count);

            var product = _productsQuery.GetProduct("Contacts5");
            var order   = _ordersCommand.PrepareOrder(new[] { product.Id }, null, null, CreditCardType.MasterCard);

            _ordersCommand.PurchaseOrder(employer.Id, order, CreatePurchaser(employer.Id), CreateCreditCard());

            AssertOrders(new[] { order }, new[] { employer });
        }
コード例 #4
0
        private void DeleteProduct(int index)
        {
            // If it already exists then delete it.

            var name    = string.Format(ProductNameFormat, index);
            var product = _productsQuery.GetProduct(name);

            if (product != null)
            {
                _productsRepository.DeleteProduct(product.Id);
            }
        }
コード例 #5
0
        protected Order CreateOrder(IPurchasesCommand puchasesCommand)
        {
            var product = _productsQuery.GetProduct("Contacts5");

            IOrdersCommand ordersCommand = new OrdersCommand(
                Resolve <IOrdersRepository>(),
                Resolve <IOrderPricesCommand>(),
                _productsQuery,
                Resolve <IAllocationsCommand>(),
                Resolve <IAllocationsQuery>(),
                puchasesCommand);

            return(ordersCommand.PrepareOrder(new[] { product.Id }, null, null, CreateCreditCard(AustralianCreditCardNumber).CardType));
        }