private CosmeticsEngine() { this.factory = new CosmeticsFactory(); this.shoppingCart = new ShoppingCart(); this.categories = new Dictionary<string, ICategory>(); this.products = new Dictionary<string, IProduct>(); }
public ReviewOrderViewModelBuilder(CheckoutDetailsModel checkoutDetailsModel, IShoppingCart shoppingCart, CartItemViewModelBuilder cartItemViewModelBuilder , IMappingEngine mapper) { this.checkoutDetailsModel = checkoutDetailsModel; this.shoppingCart = shoppingCart; this.cartItemViewModelBuilder = cartItemViewModelBuilder; this.mapper = mapper; }
public OrderConfirmationEmailTemplateViewModelBuilder(string orderNumber, CheckoutDetailsModel model, IShoppingCart shoppingCart, CartItemViewModelBuilder cartItemBuilder) { this.orderNumber = orderNumber; this.model = model; this.shoppingCart = shoppingCart; this.cartItemBuilder = cartItemBuilder; }
public ShoppingCartController(IShoppingCart shoppingCart, IOrchardServices services, IWebshopSettingsService webshopSettings, IOrderService orderService) { _shoppingCart = shoppingCart; _services = services; _webshopSettings = webshopSettings; _orderService = orderService; }
public ShoppingCartViewModelBuilder(IShoppingCart shoppingCart, IJewelRepository jewelRepository, CartItemViewModelBuilder cartItemViewModelBuilder, IAuthentication authentication, IMappingEngine mapper) { this.shoppingCart = shoppingCart; this.jewelRepository = jewelRepository; this.cartItemViewModelBuilder = cartItemViewModelBuilder; this.authentication = authentication; this.mapper = mapper; }
public CheckoutController(IOrchardServices services, IAuthenticationService authenticationService, ICustomerService customerService, IMembershipService membershipService,IShoppingCart shoppingCart) { _authenticationService = authenticationService; _services = services; _customerService = customerService; _membershipService = membershipService; _shoppingCart = shoppingCart; T = NullLocalizer.Instance; }
/// <summary> /// /// </summary> /// <param name="shoppingCart"></param> /// <returns></returns> public Reciept CheckOutAndCalculate(IShoppingCart shoppingCart) { if (shoppingCart == null || shoppingCart.ShoppingItems.Count == 0) { throw new ArgumentException("Shopping cart is empty"); } var shoppingItems = shoppingCart.GroupShoppingItems(); return(_calculatePrice.Calculate(shoppingItems)); }
public CosmeticsEngine( ICosmeticsFactory factory, IShoppingCart shoppingCart, ICommandParser commandParser) { this.factory = factory; this.shoppingCart = shoppingCart; this.commandParser = commandParser; this.categories = new Dictionary<string, ICategory>(); this.products = new Dictionary<string, IProduct>(); }
public IEnumerable <APIUsers.Library.Models.ShoppingCart> GetShoppingCart_Products(int id) { List <APIUsers.Library.Models.ShoppingCart> listCart = new List <APIUsers.Library.Models.ShoppingCart>(); using (IShoppingCart Shopping = Factorizador.CrearConexionServicioShoppingCart(APIUsers.Library.Models.ConnectionType.MSSQL, ConnectionStringLocal)) { listCart = Shopping.getShoppingCart(id); } return(listCart); }
internal void GetCartFromSession() { if (Session["cart"] != null) { shoppingCart = (IShoppingCart)Session["cart"]; } else { shoppingCart = new ShoppingCart(); } }
public static async Task <bool> RunOrchestrator( [OrchestrationTrigger] IDurableOrchestrationContext context) { var userId = context.GetInput <string>(); var shoppingCartEntity = new EntityId(nameof(ShoppingCartEntity), userId); var inventoryEntity = new EntityId(nameof(InventoryEntity), "onestore"); var orderEntity = new EntityId(nameof(OrderEntity), userId); // Create a critical section to avoid race conditions. using (await context.LockAsync(inventoryEntity, orderEntity, shoppingCartEntity)) { IShoppingCart shoppingCartProxy = context.CreateEntityProxy <IShoppingCart>(shoppingCartEntity); IInventory inventoryProxy = context.CreateEntityProxy <IInventory>(inventoryEntity); IOrder orderProxy = context.CreateEntityProxy <IOrder>(orderEntity); var shoppingCartItems = await shoppingCartProxy.GetItemsAsync(); var orderItem = new OrderItem() { Timestamp = DateTime.UtcNow, UserId = userId, Details = shoppingCartItems }; var canSell = true; foreach (var inventoryItem in orderItem.Details) { if (await inventoryProxy.IsItemInInventory(inventoryItem)) { await inventoryProxy.RemoveStockAsync(inventoryItem); await shoppingCartProxy.RemoveItemAsync(inventoryItem); } else { canSell = false; break; } } if (canSell) { await orderProxy.AddAsync(orderItem); // order placed successfully return(true); } // the order failed due to insufficient stock return(false); } }
protected void dgvSearchResult_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "IncreaseBookInCart") { shoppingCart = Task.Run(() => AddOrRemoveFromCart(int.Parse(e.CommandArgument.ToString()), true)).Result; Session["cart"] = shoppingCart; BindDataToDgv(dgvCart, shoppingCart.BooksInCart); BindDataToDgv(dgvSearchResult, null); } }
public PlaceOrderUseCase( IOrderService orderService, IOrderRepository orderRepository, IShoppingCart shoppingCart, IShoppingCartStateStore shoppingCartStateStore) { this.orderService = orderService; this.orderRepository = orderRepository; this.shoppingCart = shoppingCart; this.shoppingCartStateStore = shoppingCartStateStore; }
public double CalculateFor(IShoppingCart cart) { if (cart == null) { throw new ArgumentNullException(); } var numberOfDeliveries = cart.GetNumberOfDeliveries(); var numberOfProducts = cart.GetNumberOfProducts(); return((_costPerDelivery * numberOfDeliveries) + (_costPerProduct * numberOfProducts) + _fixedCost); }
public IOrder CreateOrder( IShoppingCart cart ) { var result = new Order { Id = Guid.NewGuid() }; using( var context = new Context() ) { result.ShoppingCart = context.ShoppingCarts.Single( n => n.Id == cart.Id ); context.Orders.Add( result ); context.SaveChanges(); } return result; }
public async Task <IShoppingCart> GetCartAsync() { if (!_carts.Keys.Contains(_httpContextAccessor.HttpContext.Session.Id)) { _carts[_httpContextAccessor.HttpContext.Session.Id] = new ShoppingCart(_productService, _couponService); } IShoppingCart cart = _carts[_httpContextAccessor.HttpContext.Session.Id]; // TODO: Remove this demonstration wait. await Task.Delay(100); return(cart); }
public double CalculateFor(IShoppingCart shoppingCart) { //If there is no product, so there is no item to deliver. This mean, its delivery cost should be 0. if (shoppingCart.GetNumberOfProducts() == 0) { return(0.0); } return(CostPerDelivery * shoppingCart.GetNumberOfDeliveries() + CostPerProduct * shoppingCart.GetNumberOfProducts() + FixedCost); }
public Guid PlaceOrder(Guid customerId, IShoppingCart shoppoingShoppingCart) { var order = new Order(); //Business logic that valiedates order and creates Order object var orderId = Save(order); _customerService.AddOrderToCustomer(customerId, orderId); _loggingService.LogNewOrder(orderId); return(orderId); }
public void UpdateItem(IShoppingCart cart, IProduct product, int qty) { using (var connection = new SqlConnection(_dbOptions.ConnectionString)) { connection.Execute("UPDATE ShoppingCartItems SET Qty = @qty WHERE ShoppingCartId = @cartId AND ProductId = @productId", new { cartId = cart.ShoppingCartId, productId = product.ProductID, qty }); } }
public bool Clear(IShoppingCart _lineCollection) { try { _lineCollection.lines.Clear(); } catch (Exception exc) { return(false); } return(true); }
public double CalculateFor(IShoppingCart shoppingCart) { Guard.Against.Null(shoppingCart, nameof(shoppingCart)); if (shoppingCart.NumberOfDeliveries == 0 && shoppingCart.NumberOfProducts == 0) { return(0); } return((CostPerDelivery * shoppingCart.NumberOfDeliveries) + (CostPerProduct * shoppingCart.NumberOfProducts) + _fixedCost); }
public bool RemoveItem(ItemDTO item, IShoppingCart _lineCollection) { try { _lineCollection.lines.RemoveAll(l => l.Item.ItemId == item.ItemId); } catch (Exception exc) { return(false); } return(true); }
public void Test_Initialize() { _cart = new Cart(); _testProduct = new Product { ProductId = 1, CategoryId = 1, Description = "test product", Name = "test product", Price = 17 }; }
public ProductsRequireAuthenticationCheckoutCondition( IShoppingCart shoppingCart, INotifier notifier, IWorkContextAccessor workContextAccessor) { _shoppingCart = shoppingCart; _notifier = notifier; _workContextAccessor = workContextAccessor; T = NullLocalizer.Instance; Url = new UrlHelper(_workContextAccessor.GetContext().HttpContext.Request.RequestContext); }
public async Task <IActionResult> OnPostAsync(int productId, int quantity) { IShoppingCart cart = await _shoppingCartService.GetCartAsync(); IShoppingCartItem item = cart.Items.First(o => o.Product.ProductId == productId); if (item == null) { throw new ArgumentException("Could not find that product."); } item.Quantity = quantity; return(RedirectToPage("/Cart/Index")); }
public CheckoutController(IOrchardServices services, IAuthenticationService authenticationService, ICustomerService customerService, IMembershipService membershipService, IShoppingCart shoppingCart, IWebshopSettingsService webshopSettings, IMessageManager messageManager) { _authenticationService = authenticationService; _services = services; _customerService = customerService; _membershipService = membershipService; _shoppingCart = shoppingCart; _webshopSettings = webshopSettings; _messageManager = messageManager; T = NullLocalizer.Instance; }
static void Main(string[] args) { var container = Initer.Load(); IShoppingCart cart = container.Resolve <IShoppingCart>(); cart.Checkout("car"); Console.WriteLine("-------------------"); ICalculator svc = container.Resolve <ICalculator>(); var ss = svc.Add(1, 2); Console.ReadKey(); }
public void GivenEmptyShoppingCart_WhenAddingProductItem_ThenContainsExpectedProductItem() { // Arrange var productItem = Mock.Of <IProductItem>(); IShoppingCart shoppingCart = CreateShoppingCart(); // Act shoppingCart.AddProductItem(productItem); // Assert Assert.That(shoppingCart.ProductItems.First(), Is.EqualTo(productItem)); }
public ShoppingCartWindow(IShoppingCart shoppingCart, IUserContext loggedUser, IUserService user, IProductService productService, IOrderService order, TextBlock total) { InitializeComponent(); this.shoppingCart = shoppingCart; this.loggedUser = loggedUser; this.user = user; this.productService = productService; this.order = order; this.total = total; this.cardInfo = new List <TextBox>(); FillInfo(); }
public void TestInitialize() { var mockProduct = new Mock <IProduct>(); mockProduct.SetupGet(s => s.name).Returns("Конфеточки"); mockProduct.SetupGet(s => s.price).Returns(125); mockProduct.SetupGet(s => s.isOnSale).Returns(true); mockProduct.SetupGet(s => s.countNeedToBuyForSale).Returns(3); mockProduct.SetupGet(s => s.salePrice).Returns(300); sweet = mockProduct.Object; cart = new ShoppingCart(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["cart"] != null) { shoppingCart = (IShoppingCart)Session["cart"]; } CheckAndSplitByOrderability(); //reset cart Session["cart"] = null; }
public OrderController(IShapeFactory shapeFactory, IOrderService orderService, IAuthenticationService authenticationService, IShoppingCart shoppingCart, ICustomerService customerService, IEnumerable<IPaymentServiceProvider> paymentServiceProviders, IMessageManager messageManager, IWebshopSettingsService webshopSettings) { _shapeFactory = shapeFactory; _orderService = orderService; _authenticationService = authenticationService; _shoppingCart = shoppingCart; _customerService = customerService; _t = NullLocalizer.Instance; _paymentServiceProviders = paymentServiceProviders; _messageManager = messageManager; _webshopSettings = webshopSettings; }
public void Print(IShoppingCart shoppingCart) { Console.WriteLine(""); if (shoppingCart.CartItems.Count < 1) { Console.WriteLine("Shopping Cart is empty"); } else { shoppingCart.CartItems.ForEach(art => Console.WriteLine($"- Article: { art.SelectedItem.ItemName } - Qty: {art.Amount.ToString()}")); } Console.WriteLine(""); }
public CosmeticsEngine ( ICosmeticsFactory fact, IShoppingCart cart, IDictionary <string, ICategory> categ, IDictionary <string, IProduct> products ) { this.factory = fact; this.shoppingCart = cart; this.categories = categ; //categ; this.products = products; //products; }
public CheckoutController(IOrchardServices services, IAuthenticationService authenticationService, ICustomerService customerService, IMembershipService membershipService, IShoppingCart shoppingCart, IWebshopSettingsService webshopSettings, ISmtpChannel email) { _authenticationService = authenticationService; _services = services; _customerService = customerService; _membershipService = membershipService; _shoppingCart = shoppingCart; _webshopSettings = webshopSettings; _email = email; //_messageManager = messageManager; T = NullLocalizer.Instance; }
public ActionResult Index() { string cartId = cardIdentifier.GetCardId(this.HttpContext); IShoppingCart cart = shoppingCart.GetShoppingCart(cartId); ShoppingCartViewModel viewModel = new ShoppingCartViewModel(); viewModel.CartItems = cart.GetCartItems(); viewModel.CartTotal = cart.GetTotal(); ViewBag.City = TempData["City"]; return(View(viewModel)); }
public CosmeticsEngine( ICosmeticsFactory factory, IShoppingCart shoppingCart, ICommandParser commandParser, IWriter writer) { this.factory = factory; this.shoppingCart = shoppingCart; this.commandParser = commandParser; this.writer = writer; this.categories = new Dictionary <string, ICategory>(); this.products = new Dictionary <string, IProduct>(); }
public IShoppingCartItem AddItemToCart(ProductOffer productOffer, IShoppingCart cart ) { var result = new ShoppingCartItem { Id = Guid.NewGuid(), Created = System.DateTime.Now }; using( var context = new Context() ) { result.ShoppingCart = context.ShoppingCarts.Single( n => n.Id == cart.Id ); result.ProductOffer = context.ProductOffers.Single( n => n.Id == productOffer.Id ); context.ShoppingCartItems.Add( result ); context.SaveChanges(); } return result; }
public ShippingModel(ILogger <ShippingModel> logger, IShoppingCart shoppingCart, IOrderRepository orderRepository, UserManager <ApplicationUser> userManager, IMailService mailService, IRazorPartialToStringRenderer razorPartialToString) { this.logger = logger; this.shoppingCart = shoppingCart; this.orderRepository = orderRepository; this.userManager = userManager; this.mailService = mailService; this.razorPartialToString = razorPartialToString; }
// We're using HttpContextBase to allow access to sessions. private async static Task <string> GetCartIdAsync(IShoppingCart shoppingCart, HttpContext context) { var cartId = context.Session.GetString("Session"); if (cartId == null) { //A GUID to hold the cartId. cartId = Guid.NewGuid().ToString(); context.Session.SetString("Session", cartId); } var result = await shoppingCart.CreateCartAsync(cartId); return(cartId); }
public OrderController( IShapeFactory shapeFactory, IOrderService orderService, IAuthenticationService authenticationService, IShoppingCart shoppingCart, ICustomerService customerService ) { _shapeFactory = shapeFactory; _orderService = orderService; _authenticationService = authenticationService; _shoppingCart = shoppingCart; _customerService = customerService; _t = NullLocalizer.Instance; }
public ShoppingCartController( IShoppingCart shoppingCart, IShapeFactory shapeFactory, IContentManager contentManager, IWorkContextAccessor wca, IEnumerable<ICheckoutService> checkoutServices, IEnumerable<IShippingMethodProvider> shippingMethodProviders, IEnumerable<IExtraCartInfoProvider> extraCartInfoProviders) { _shippingMethodProviders = shippingMethodProviders; _shoppingCart = shoppingCart; _shapeFactory = shapeFactory; _contentManager = contentManager; _wca = wca; _checkoutServices = checkoutServices; _extraCartInfoProviders = extraCartInfoProviders; }
private ShoppingCartViewModelBuilder CreateDefaultShoppingCartViewModelBuilderWithShoppingCartAsParameter(IShoppingCart shoppingCart) { var jewelryRepository = new FakeJewelRepository(new FakeSettingManager()); var diamondRepository = new FakeDiamondRepository(mapper); var cartItemViewModelBuilder = new CartItemViewModelBuilder(jewelryRepository, diamondRepository, mapper); var authentication = MockRepository.GenerateStub<IAuthentication>(); var builder = new ShoppingCartViewModelBuilder(shoppingCart, jewelryRepository, cartItemViewModelBuilder, authentication, mapper); return builder; }
public ShoppingCartController(IShoppingCartRepository shoppingCartRepository, IShoppingCart shoppingCart) { repository = shoppingCartRepository; cart = shoppingCart; }
public ShoppingCartController() { repository = new ShoppingCartRepository(); cart = new ShoppingCart(); }
public OrderBuilder(IShoppingCart shoppingCart, IAuthentication authentication, IMappingEngine mapper) { this.shoppingCart = shoppingCart; this.authentication = authentication; this.mapper = mapper; }
private int SaveOrderAndEmail(CheckoutDetailsModel checkoutDetailsModel, IShoppingCart shoppingCart) { var orderBuilder = new OrderBuilder(shoppingCart, authentication, mapper); var orderdto = orderBuilder.Build(checkoutDetailsModel); var orderNumber = orderRepository.Save(orderdto); if (orderNumber > 0) { var cartItemBuilder = new CartItemViewModelBuilder(jewelRepository, diamondRepository, mapper); var emailTemplateBuilder = new OrderConfirmationEmailTemplateViewModelBuilder(orderNumber.ToString(), checkoutDetailsModel, shoppingCart, cartItemBuilder); var emailTemplateViewModel = emailTemplateBuilder.Build(); mailer.OrderConfirmation(checkoutDetailsModel.Email, emailTemplateViewModel).Send(); } return orderNumber; }
public void Presist(IShoppingCart shoppingCart,HttpContextBase httpContextBase) { httpContextBase.Session["cart"] = shoppingCart; }
public ShoppingCartController(IMusicRepo repo, IShoppingCart cart) { _repo = repo; _cart = cart; _cartid = MvcApplication.GetCartId(); }
public MockedCosmeticsEngine(ICosmeticsFactory factory, IShoppingCart shoppingCart, ICommandParser commandParser) : base(factory, shoppingCart, commandParser) { }
public ShoppingCartController(IShoppingCart shoppingCart, IOrchardServices services) { _shoppingCart = shoppingCart; _services = services; }
public ShoppingCartController(IShoppingCart shoppingCart,IOrchardServices orchardService) { _shoppingCart = shoppingCart; _orchardServices = orchardService; }
private void PersistShoppingCart(IShoppingCart shoppingCart) { // Models.Checkout.ShoppingCart.Persist(HttpContext, shoppingCart); shoppingCartWrapper.Presist(shoppingCart, HttpContext); }
public HomeController(IValueCalculator calculator, IShoppingCart cart, IValueCalculator calc) { this.calculator = calculator; this.cart = cart; cart.Products = this.products; }