public ServiceResult GetPriceRules() { if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } PriceManager financeManager = new PriceManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); List <dynamic> PriceRule = (List <dynamic>)financeManager.GetPriceRules(CurrentUser.AccountUUID, false).Cast <dynamic>().ToList(); DataFilter filter = this.GetFilter(Request); PriceRule = PriceRule.Filter(ref filter); return(ServiceResponse.OK("", PriceRule, filter.TotalRecordCount)); }
public ServiceResult GetPriceRules(string filter = "") { if (CurrentUser == null) { return(ServiceResponse.Error("You must be logged in to access this function.")); } PriceManager financeManager = new PriceManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); List <dynamic> PriceRule = (List <dynamic>)financeManager.GetPriceRules(CurrentUser.AccountUUID, false).Cast <dynamic>().ToList(); int count; DataFilter tmpFilter = this.GetFilter(filter); PriceRule = FilterEx.FilterInput(PriceRule, tmpFilter, out count); return(ServiceResponse.OK("", PriceRule, count)); }
//Todo optimize this process. Cache on client and cache here. // add better data retrieval.. // private CartView GetCartView(ShoppingCart cart) { CartView cv = new CartView(); try { var config = new MapperConfiguration(cfg => { cfg.CreateMap <ShoppingCart, CartView>(); }); IMapper mapper = config.CreateMapper(); cv = mapper.Map <ShoppingCart, CartView>(cart); } catch (Exception ex) { SystemLogger logger = new SystemLogger(Globals.DBConnectionKey); logger.InsertException(ex, "StoreController", "GetCartView", ContextHelper.GetContextData()); return(cv); } StoreManager storeManager = new StoreManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); cv.CartItems = storeManager.GetItemsInCart(cv.UUID); PriceManager cm = new PriceManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); cv.PriceRules = cm.GetPriceRules(cv.UUID, "shoppingcart"); LocationManager lm = new LocationManager(Globals.DBConnectionKey, this.GetAuthToken(Request)); var resb = lm.Get(cv.BillingLocationUUID); if (resb.Code == 200) { cv.BillingAddress = (Location)resb.Result; } if (cv.ShippingSameAsBiling == false) { var resc = lm.Get(cv.ShippingLocationUUID); if (resc.Code == 200) { cv.ShippingAddress = (Location)resc.Result; } } return(cv); }
//Todo optimize this process. Cache on client and cache here. // add better data retrieval.. // private CartView GetCartView(ShoppingCart cart) { CartView cv = new CartView(); try { var config = new MapperConfiguration(cfg => { cfg.CreateMap <ShoppingCart, CartView>(); }); IMapper mapper = config.CreateMapper(); cv = mapper.Map <ShoppingCart, CartView>(cart); } catch (Exception ex) { SystemLogger logger = new SystemLogger(Globals.DBConnectionKey); logger.InsertException(ex, "StoreController", "GetCartView", ContextHelper.GetContextData()); return(cv); } StoreManager storeManager = new StoreManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); cv.CartItems = storeManager.GetItemsInCart(cv.UUID); PriceManager cm = new PriceManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); cv.PriceRules = cm.GetPriceRules(cv.UUID, "shoppingcart"); LocationManager lm = new LocationManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter); cv.BillingAddress = (Location)lm.GetBy(cv.BillingLocationUUID); if (cv.ShippingSameAsBiling == false) { cv.ShippingAddress = (Location)lm.GetBy(cv.ShippingLocationUUID); } return(cv); }