Skip to content

Instantly share code, notes, and snippets.

@mattbrailsford
Created May 17, 2019 14:00
Show Gist options
  • Save mattbrailsford/6446b15b39cd33544d71b92ce9a27f21 to your computer and use it in GitHub Desktop.
Save mattbrailsford/6446b15b39cd33544d71b92ce9a27f21 to your computer and use it in GitHub Desktop.
// All service have access to an ISessionManager that persists
// the current ids for the session (ISessionManager interface
// defined in core, with implementation in web project to
// store values in session / cookies OOTB)
OrderService.Get/SetCurrentOrder();
CurrencyService.Get/SetCurrentCurrency();
CountryService.Get/SetCurrentPaymentCountry();
CountryService.Get/SetCurrentPaymentRegion();
CountryService.Get/SetCurrentShippingCountry();
CountryService.Get/SetCurrentShippingRegion();
PaymentMethodService.Get/SetCurrentPaymentMethod();
ShippingMethodService.Get/SetCurrentShippingMethod();
// Example
var order = OrderService.GetCurrentOrder(storeId);
order.Items.AddOrUpdate(...);
OrderService.SaveOrder(order);
// Concerns
"Current" setting/getting is split across multiple services so
requires accessing multiple end points. More confusing?
// Services are ISessionManager un-aware and instead
// the SessionManager stores and accesses session
// related entities. SessionManager then become the
// interface to get/set all session related entities
SessionManager.Get/SetCurrentOrder();
SessionManager.Get/SetCurrentCurrency();
SessionManager.Get/SetCurrentPaymentCountry();
SessionManager.Get/SetCurrentPaymentRegion();
SessionManager.Get/SetCurrentShippingCountry();
SessionManager.Get/SetCurrentShippingRegion();
SessionManager.Get/SetCurrentPaymentMethod();
SessionManager.Get/SetCurrentShippingMethod();
// Example
var order = SessionManager.GetCurrentOrder(storeId); // Get via session manager
order.Items.AddOrUpdate(...);
OrderService.SaveOrder(order); // Save via order service
// Concerns
Disparate that you get from SessionManager but you'd still
need to go via the OrderService etc to save any changes back
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment