private void loadPromotion() { var info = HttpContext.Current.Session[sessionKey] as PromotionCollection; if (null == info) { const string format = "MM-dd-yyyy"; info = PromotionConfigurationProvider.GetPromotionCollection(HLConfigManager.Platform, "zh-CN"); if (info != null) { DateTime currentDateTime = DateUtils.GetCurrentLocalTime("CN"); PromotionCollection col = new PromotionCollection(); foreach (var promoItem in info) { DateTime startDateTime = convertDateTime(promoItem.StartDate); DateTime endDateTime = convertDateTime(promoItem.EndDate); if (startDateTime != DateTime.MaxValue && endDateTime != DateTime.MaxValue) { if (startDateTime <= currentDateTime && endDateTime > currentDateTime) { col.Add(promoItem); } } } HttpContext.Current.Session[sessionKey] = col; } } }
protected void Page_Load(object sender, EventArgs e) { (Master as OrderingMaster).SetPageHeader("贵宾客户满意度问卷调查"); lblError.Text = string.Empty; pInfo = PromotionConfigurationProvider.GetPromotionCollection(HLConfigManager.Platform, "zh-CN");; Session["AttainedSurvey"] = false; }
public void TestMethod1() { PromotionCollection promotions = new PromotionCollection(); SimplePricePromotion spp = new SimplePricePromotion(); spp.Product = "Apple"; spp.Price = 0.5M; spp.Period = new kiosk.Model.EffectiveDate(new DateTime(2017, 03, 01), new DateTime(2017, 04, 01)); GroupFixedPricePromotion gfpp = new GroupFixedPricePromotion(); gfpp.Period = new kiosk.Model.EffectiveDate(new DateTime(2011, 03, 01), new DateTime(2021, 04, 01)); gfpp.Product = "Pen"; gfpp.Quantity = 10; gfpp.Price = 9.99M; GroupFixedPricePromotion gfppspat = new GroupFixedPricePromotion(); gfpp.Period = new kiosk.Model.EffectiveDate(new DateTime(2011, 03, 01), new DateTime(2021, 04, 01)); gfpp.Product = "Spatula"; gfpp.Quantity = 10; gfpp.Price = 7.77M; promotions.Add(spp); promotions.Add(gfpp); promotions.Add(gfppspat); kiosk.Data.XmlSource.Save(promotions, "promotions.xml"); }
private void Process() { DateTime orderProcessDate; // Datetime the order is placed. Will determine pricing and promotions ViewEntity.IGroceryView view = null; //Our "view" - the console in this case but could be windows/web // Ordinarily the controller would work with a specific ViewEntity Interface // and bind controls to a concrete implementation of that interface. // For simplicity sake, there are no console "UI controls" but there could be. ProductCollection products = null; // List of products in the user's shopping list GroceryOrder groceryOrder = null; // The Order containing line items and pricing Catalog catalog = null; PromotionCollection promotions = null; try { view = new CommandlineView(); view.Bind(Exceptions); // bind our view to an errors collection so that it can notify the user of any errors //Load our source data // Customer's shopping list products = Data.XmlSource.Load(typeof(ProductCollection), _shoppingList.ToString()) as ProductCollection; //Promotions database promotions = Data.XmlSource.Load(typeof(PromotionCollection), "promotions.xml") as Model.Offer.PromotionCollection; //Declare and load the Pricebook catalog = Data.XmlSource.Load(typeof(Catalog), "catalog.xml") as Catalog; if (DateTime.TryParse(_orderDate, out orderProcessDate)) { groceryOrder = new GroceryOrder(products, orderProcessDate, catalog, promotions); view.Bind(groceryOrder); //Ideally we would bind to something implementing IGroceryOrder // but due to the xml serializer, I had to resort to using concrete classes. groceryOrder.Process(); //Process the user's shopping list and generate the output } else { throw new Model.Exceptions.Validation.InvalidDateTimeCastException(string.Format("Unable to convert \"{0}\" to a valid datetime. Please correct this and resubmit.", _orderDate)); } } catch (Exception ex) { if (Exceptions != null) { Exceptions.Add(ex); } } finally { } }
public PromotionCollection GetPromotionCollectionMock() { PromotionCollection promotionCollection = new PromotionCollection(); PromotionElement pe = new PromotionElement { FreeSKUList = new FreeSKUCollection { new FreeSKU { Quantity = 1, SKU = "376P" } }, AmountMax = -1, AmountMaxInclude = -1, AmountMin = -1, AmountMinInclude = -1, Code = "00014", CustCategoryTypeList = new List <string>(), SelectableSKUList = new FreeSKUCollection { new FreeSKU { Quantity = 1, SKU = "1447" } }, StartDate = Convert.ToDateTime("2016-02-01 00:00:00").ToString(CultureInfo.InvariantCulture), EndDate = Convert.ToDateTime("2016-02-28 11:59:59 PM").ToString(CultureInfo.InvariantCulture), excludedExpID = new List <string>(), VolumeMax = -1, VolumeMaxInclude = -1, VolumeMin = -1, VolumeMinInclude = 200, CurrentConfiguration = { }, CustCategoryType = "", CustType = "", LockAllAttributesExcept = { }, LockItem = false, LockAttributes = { }, LockElements = { }, PromotionType = PromotionType.Volume, NumOfMonth = 1, MaxFreight = -1, OnlineOrderOnly = false, FreeSKUListForSelectableSku = new FreeSKUCollection(), FreeSKUListForVolume = new FreeSKUCollection(), ForPC = false, CustTypeList = new List <string> { "DS,PC,FM,SR" }, DSStoreProvince = new List <string>(), DeliveryTypeList = new List <string>() }; promotionCollection.Add(pe); return(promotionCollection); }
public GroceryOrder(ProductCollection customerOrder, DateTime orderDate, Catalog catalog, PromotionCollection promotions) : this(customerOrder, orderDate) { _catalog = catalog; _promotions = promotions; }