public void TestShouldUpdateProduct() { var products = productsQuery.GetProducts(); var product = products.Items.First(); var productsCommandValidator = new ProductsCommandValidator(); var results = productsCommandValidator.ValidateUpdateProduct(product.Id, product); Assert.IsTrue(results.Count == 0); }
public void TestProductCoupon() { var product1 = _productsQuery.GetProducts(UserType.Employer)[1]; var product2 = _productsQuery.GetProducts(UserType.Employer)[2]; var coupon = CreateCoupon(0, true, null, null, new[] { product1.Id }); AssertJsonError(Coupon(HttpStatusCode.Forbidden, coupon.Code), null, "300", "The coupon does not apply to the type of products you've ordered."); AssertJsonSuccess(Coupon(coupon.Code, product1.Id)); AssertJsonError(Coupon(HttpStatusCode.Forbidden, coupon.Code, product2.Id), null, "300", "The coupon does not apply to the type of products you've ordered."); }
Product IEmployerOrdersQuery.GetJobAdFeaturePackProduct(JobAdFeaturePack featurePack) { // Get all products for employers. var products = _productsQuery.GetProducts(UserType.Employer); return((from p in products where p.Name == featurePack.ToString() select p).SingleOrDefault()); }
protected Product GetContactProduct() { // Select the first product that has a single credit adjustment for the given type. var credit = _creditsQuery.GetCredit <ContactCredit>(); return((from p in _productsQuery.GetProducts() where p.CreditAdjustments.Count == 1 && p.CreditAdjustments[0].CreditId == credit.Id select p).First()); }
public void TestShouldCreateOption() { var products = productsQuery.GetProducts(); var product = products.Items.First(); var productOptionsCommandValidator = new ProductOptionsCommandValidator(); var results = productOptionsCommandValidator.ValidateCreateOption(product.Id, new ProductOption { Name = "Navi", Description = "Navi colour", }); Assert.IsTrue(results.Count == 0); }
public static Order PrepareOrder(this IEmployerOrdersCommand employerOrdersCommand, IProductsQuery productsQuery, ICreditsQuery creditsQuery, IEnumerable <Guid> productIds, Coupon coupon, Discount discount, CreditCardType creditCardType) { var order = employerOrdersCommand.PrepareOrder(productIds, coupon, discount, creditCardType); SortItems(creditsQuery, order, productsQuery.GetProducts()); return(order); }
public ActionResult Receipt() { var order = _ordersQuery.GetOrder(Pageflow.OrderId); var products = _productsQuery.GetProducts(); return(View(new NewOrderReceiptModel { OrderSummary = _employerOrdersQuery.GetOrderSummary(_creditsQuery, _ordersQuery, order, products, CurrentRegisteredUser) })); }
private Product GetProduct <T>() where T : Credit { // Select the first product that has a single credit adjustment for the given type. var credit = _creditsQuery.GetCredit <T>(); return((from p in _productsQuery.GetProducts() where p.CreditAdjustments.Count == 1 && p.GetPrimaryCreditAdjustment().CreditId == credit.Id select p).First()); }
public void TestCreateCouponProductIds() { var coupon = CreateCoupon(0); var products = _productsQuery.GetProducts(); coupon.ProductIds = new List <Guid> { products[0].Id, products[2].Id }; _couponsCommand.CreateCoupon(coupon); AssertCoupon(coupon, _couponsQuery.GetCoupon(coupon.Id)); AssertCoupon(coupon, _couponsQuery.GetCoupon(coupon.Code)); }
void IOrdersHandler.OnOrderPurchased(Order order, PurchaseReceipt receipt) { var allProducts = _productsQuery.GetProducts(); // Reorder the items by primary credit description just to introduce some certainty. order.Items = (from i in order.Items join p in allProducts on i.ProductId equals p.Id let a = p.GetPrimaryCreditAdjustment() let c = a == null ? null : _creditsQuery.GetCredit(a.CreditId) orderby c == null ? "" : c.Description select i).ToList(); // Grab the list of products selected. var orderProducts = (from i in order.Items join p in allProducts on i.ProductId equals p.Id select p).ToList(); // Grab the list of primary properties. var orderPrimaryCredits = (from p in orderProducts let a = p.GetPrimaryCreditAdjustment() where a != null select _creditsQuery.GetCredit(a.CreditId)).ToList(); var orderPrimaryAdjustments = (from p in orderProducts let a = p.GetPrimaryCreditAdjustment() where a != null select a).ToList(); // Grab the purchaser, who is being sent the email. var purchaser = _employersQuery.GetEmployer(order.PurchaserId); _emailsCommand.TrySend(new OrderReceiptEmail(purchaser, order, orderProducts, orderPrimaryCredits, orderPrimaryAdjustments, receipt)); }
public IActionResult Get() { return(Ok(_productsQuery.GetProducts())); }
public async Task <IEnumerable <ProductQueryResult> > GetProductsAsync(int page, int itemsPerPage) { var result = await _productsQuery.GetProducts(page, itemsPerPage); return(result); }
public ActionResult Payment(Guid jobAdId, JobAdFeaturePack featurePack) { var employer = CurrentEmployer; var jobAd = GetJobAd(employer.Id, jobAdId); if (jobAd == null) { return(NotFound("job ad", "id", jobAdId)); } var product = _employerOrdersQuery.GetJobAdFeaturePackProduct(featurePack); if (product == null) { return(NotFound("feature pack", "featurePack", featurePack)); } var creditCard = new CreditCard { ExpiryDate = GetDefaultExpiryDate() }; var order = _employerOrdersCommand.PrepareOrder(new[] { product.Id }, null, null, GetCreditCardType(creditCard)); return(View(new PaymentJobAdModel { AuthoriseCreditCard = false, CouponCode = null, CreditCard = creditCard, OrderDetails = _employerOrdersQuery.GetOrderDetails(_creditsQuery, order, _productsQuery.GetProducts()), Product = product, })); }
public ActionResult PrepareCompactOrder(Guid[] productIds) { var order = GetOrder(productIds, null, null, null); return(PartialView("OrderCompactDetails", _employerOrdersQuery.GetOrderDetails(_creditsQuery, order, _productsQuery.GetProducts()))); }
public void TestCreateProductNoAdjustments() { var product = CreateProduct(1, UserType.Member, 1, null); AssertProducts(_productsQuery.GetProducts(), product); AssertProducts(_productsQuery.GetProducts(UserType.Member), product); }