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); }
public IActionResult Get(Guid id) { var product = _productsQuery.GetProduct(id); if (product == null) { return(NotFound()); } return(Ok(product)); }
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 }); }
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); } }
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)); }