static void Main(string[] args) { Console.WriteLine("Press q to quit"); var quit = false; while (!quit) { Console.WriteLine("Enter product codes eg, AABBCC"); var input = Console.ReadLine(); if (input == "q") { quit = true; } else { var pricingRepo = new PricingRepo(); var checkOutService = new CheckOutService(pricingRepo); var output = checkOutService.CheckOut(input); Console.WriteLine(output); } } }
private ICheckOutService CreateCheckOutService() { var pricingRepo = new PricingRepo(); var checkOutService = new CheckOutService(pricingRepo); return(checkOutService); }
public CheckOutDetailsForm() { InitializeComponent(); patronService = PatronServiceBean.getBean(); employeeService = EmployeeServiceBean.getBean(); mediaService = MediaServiceBean.getBean(); exchangeService = ExchangeServiceBean.getBean(); checkOutService = CheckOutServiceBean.getBean(); }
public ActionResult AddressAndPaymentNoAccount(FormCollection values) { var CheckOutService = new CheckOutService(); var CheckOut = CheckOutService.CheckOut(this.HttpContext, values); if (CheckOut.Status != "Complete") { return(RedirectToAction("AddressAndPaymentNoAccount", new { model = CheckOut })); } return(RedirectToAction("Complete", new { id = CheckOut.Order.OrderId })); }
public void ValidatesPatronId() { var checkOutService = new CheckOutService(context, holdingsServiceMock.Object); var checkout = new CheckOutViewModel { Barcode = "QA123:1", PatronId = 1 }; Assert.False(checkOutService.Checkout(checkout)); Assert.Equal("Patron with ID 1 not found", checkOutService.ErrorMessages.First()); }
public void ValidatesBarcode() { SavePatronWithId(context, 5); var checkOutService = new CheckOutService(context, holdingsServiceMock.Object); var checkout = new CheckOutViewModel { Barcode = "QA1231", PatronId = 5 }; Assert.False(checkOutService.Checkout(checkout)); Assert.Equal("Invalid holding barcode format: QA1231", checkOutService.ErrorMessages.First()); }
public void ValidatesHoldingRetrieval() { SavePatronWithId(context, 5); var checkOutService = new CheckOutService(context, holdingsServiceMock.Object); var checkout = new CheckOutViewModel { Barcode = "QA123:1", PatronId = 5 }; Assert.False(checkOutService.Checkout(checkout)); Assert.Equal("Holding with barcode QA123:1 not found", checkOutService.ErrorMessages.First()); }
public async Task <ActionResult <OrderPayment> > VerifyPayment() { var checkoutPayment = new CheckOutService(); var result = await checkoutPayment.CaptureOrder(GetOrderId()); Order order = result.Result <Order>(); var orderPayment = new OrderPayment { OrderPaymentId = order.Id }; return(Ok(orderPayment.OrderPaymentId)); }
public void ValidatesHoldingAvailability() { SaveCheckedOutHoldingWithClassification(context, "QA123"); SavePatronWithId(context, 5); var checkOutService = new CheckOutService(context, holdingsServiceMock.Object); var checkout = new CheckOutViewModel { Barcode = "QA123:1", PatronId = 5 }; Assert.False(checkOutService.Checkout(checkout)); Assert.Equal("Holding with barcode QA123:1 is already checked out", checkOutService.ErrorMessages.First()); }
public void ChecksOutMaterial() { var patron = SavePatronWithId(context, 5); var holding = SaveCheckedInHoldingWithClassification(context, "QA123"); var checkOutService = new CheckOutService(context, holdingsServiceMock.Object); var checkout = new CheckOutViewModel { Barcode = "QA123:1", PatronId = patron.Id }; var result = checkOutService.Checkout(checkout); Assert.True(result); holdingsServiceMock.Verify(s => s.CheckOut(holding, 5)); }
public void TestCartCheckOutGeneralCase() { /* * this test uses the same product store as the above one , but this time. * we are picking up extra products outside of the offer. * for eg : when we pick 2 products for buy1get1 , then we get both of them * 'for the price of 1 , but insted if we take 3 , i am assuming that , * two will get the offer and then the remaining one would have to be brought at its normal price. * the same logic would be applicable for 3for10 euro offer as well. * if we pick 4 , 3 will cost 10 on offer and the 4th one will have to brought at its normal price. * * */ ProductService productService = new ProductService(new ProductRepository()); productService.ApplyOfferToProducts(ProductType.A); productService.ApplyOfferToProducts(ProductType.B); productService.ApplyOfferToProducts(ProductType.c); Cart cart = new Cart(new ProductRepository()); int cartItmQty1 = 5; cart.AddItem(1, cartItmQty1); int cartItmQty2 = 7; cart.AddItem(2, cartItmQty2); int cartItmQty3 = 5; cart.AddItem(3, cartItmQty3); CheckOutService checkOut = new CheckOutService(); checkOut.CalcualteTotal(cart.GetTotalItemsOrdered()); Assert.AreEqual(94, checkOut.Total); // this portion of code is for displaying the results string opHead = string.Format("Item\tQuantity\tPricet\tTotal\tPromotion"); string opl1 = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "A", cartItmQty1, "20", checkOut.Buy1Get1Total, "Buy 1 Get 1 Free"); string opl2 = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "B", cartItmQty2, "4", checkOut.ThreeFor10Total, "3 for 10 Euro"); string opl3 = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "C", cartItmQty3, "2", checkOut.NoOfferTotal, ""); string tot = string.Format("\tTotal \t \t${0}", checkOut.Total); Console.WriteLine(opHead); Console.WriteLine(opl1); Console.WriteLine(opl2); Console.WriteLine(opl3); Console.WriteLine(tot); }
public async Task <ActionResult <OrderPayment> > CreatePayment(string amount, string currency) { var checkoutPayment = new CheckOutService(amount, currency); var result = await checkoutPayment.CreateOrder(); Order order = result.Result <Order>(); var orderPayment = new OrderPayment { OrderPaymentId = order.Id }; SaveOrderId(order.Id); foreach (var link in order.Links) { if (link.Rel.Equals("approve")) { orderPayment.PayPalLink = link.Href; return(Ok(orderPayment)); } } return(NotFound()); }
public CheckOutController(UserManager <ApplicationUser> userManger) { _userManager = userManger; _checkOutService = new CheckOutService(); }
public CheckOutStatistic() { InitializeComponent(); checkOutService = CheckOutServiceBean.getBean(); }
public void GenerateReport( int orderId, CheckOutService checkOutService) { /* calls checkOutService when generation is completed */ }
public CheckOutController(LibraryContext _context, CheckOutService checkOutService, BranchesService branchesService) { this.checkOutService = checkOutService; this.branchesService = branchesService; }
public CheckOutForm() { InitializeComponent(); checkOutService = CheckOutServiceBean.getBean(); }
public void TestCartCheckOut() { // we need to be able to apply offers to a specific group of products.[like all products in a // given category or something . // For the purpose of demonstration i am interchanginly using ProductName as ProductType because // it would be easy to add new products in future and apply same discount all the products of the same type if we wish so. /* * List<Product> products = new List<Product>() * { * new Product{Id=1,Name=ProductType.A,Price=new Price(20)}, * new Product{Id=2,Name=ProductType.B,Price=new Price(4)}, * new Product{Id=3,Name=ProductType.c,Price=new Price(2)} * }; * * this is the product store we are dealing with right now in these unit tests. * * */ ProductService productService = new ProductService(new ProductRepository()); productService.ApplyOfferToProducts(ProductType.A); productService.ApplyOfferToProducts(ProductType.B); productService.ApplyOfferToProducts(ProductType.c); Cart cart = new Cart(new ProductRepository()); // to add a product to the cart , we give the productID and no of Products; int cartItmQty1 = 2; cart.AddItem(1, cartItmQty1); int cartItmQty2 = 3; cart.AddItem(2, cartItmQty2); int cartItmQty3 = 5; cart.AddItem(3, cartItmQty3); CheckOutService checkOut = new CheckOutService(); checkOut.CalcualteTotal(cart.GetTotalItemsOrdered()); Assert.AreEqual(40, checkOut.Total); // this portion of code is for displaying the results string opHead = string.Format("Item\tQuantity\tPricet\tTotal\tPromotion"); string opl1 = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "A", cartItmQty1, "20", checkOut.Buy1Get1Total, "Buy 1 Get 1 Free"); string opl2 = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "B", cartItmQty2, "4", checkOut.ThreeFor10Total, "3 for 10 Euro"); string opl3 = string.Format("{0}\t{1}\t${2}\t${3}\t{4}", "C", cartItmQty3, "2", checkOut.NoOfferTotal, ""); string tot = string.Format("\tTotal \t \t${0}", checkOut.Total); Console.WriteLine(opHead); Console.WriteLine(opl1); Console.WriteLine(opl2); Console.WriteLine(opl3); Console.WriteLine(tot); }
public CheckOutInsertUpdateForm(CheckOutForm checkOutForm) { InitializeComponent(); this.checkOutForm = checkOutForm; checkOutService = CheckOutServiceBean.getBean(); }