public static IPromocode createPromo(PromoType type) { IPromocode instance = null; switch (type) { case PromoType.FreeBookPromo: instance = new FreeBookPromo(new PaperBook("Harry Potter 10", "J.K. Rowling", 0)); break; case PromoType.FreeDeliveryPromo: instance = new FreeDeliveryPromo(); break; case PromoType.PercentagePromo: instance = new PercentagePromo(20); break; case PromoType.MoneyPromo: instance = new MoneyPromo(100); break; default: break; } return(instance); }
public ActionResult DeleteConfirmed(int id) { PromoType promotype = db.PromoTypes.Single(p => p.PromoTypeID == id); db.PromoTypes.DeleteObject(promotype); db.SaveChanges(); return(RedirectToAction("Index")); }
public void RequestPromo(PromoType promo) { // Don't request if promo has previously been completed or if controllers are disabled. if (!PlayerPrefs.HasKey(m_Factories[promo].PrefsKey) && App.UserConfig.Flags.ShowControllers) { m_RequestedPromos.Add(m_Factories[promo].CreateInstance()); } }
// // GET: /PromoType/Delete/5 public ActionResult Delete(int id = 0) { PromoType promotype = db.PromoTypes.Single(p => p.PromoTypeID == id); if (promotype == null) { return(HttpNotFound()); } return(View(promotype)); }
public ActionResult Edit(PromoType promotype) { if (ModelState.IsValid) { db.PromoTypes.Attach(promotype); db.ObjectStateManager.ChangeObjectState(promotype, EntityState.Modified); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(promotype)); }
public ActionResult Create(PromoType promotype) { if (ModelState.IsValid) { db.PromoTypes.AddObject(promotype); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(promotype)); }
private void LoadOptions() { PromoType clsPromoType = new PromoType(); DataClass clsDataClass = new DataClass(); cboPromoType.DataTextField = "PromoTypeCode"; cboPromoType.DataValueField = "PromoTypeID"; cboPromoType.DataSource = clsPromoType.ListAsDataTable().DefaultView; cboPromoType.DataBind(); cboPromoType.SelectedIndex = cboPromoType.Items.Count - 1; clsPromoType.CommitAndDispose(); }
private void LoadOptions() { PromoType clsPromoType = new PromoType(); DataClass clsDataClass = new DataClass(); cboPromoType.DataTextField = "PromoTypeCode"; cboPromoType.DataValueField = "PromoTypeID"; cboPromoType.DataSource = clsPromoType.ListAsDataTable().DefaultView; cboPromoType.DataBind(); cboPromoType.SelectedIndex = cboPromoType.Items.Count - 1; clsPromoType.CommitAndDispose(); txtStartDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); txtStartTime.Text = "00:00"; txtEndDate.Text = DateTime.Now.AddDays(30).ToString("yyyy-MM-dd"); txtEndTime.Text = "23:59"; }
// Record the number of times a promo has been completed. public void RecordCompletion(PromoType promo) { BasePromo[] removed = m_RequestedPromos.Where(p => p.PrefsKey == m_Factories[promo].PrefsKey).ToArray(); foreach (BasePromo p in removed) { p.OnComplete(); m_RequestedPromos.Remove(p); } string key = m_Factories[promo].PrefsKey; if (PlayerPrefs.HasKey(key)) { PlayerPrefs.SetInt(key, PlayerPrefs.GetInt(key) + 1); } else { PlayerPrefs.SetInt(key, 1); } }
public PromoFactory(PromoType type, string keySuffix) { m_Type = type; m_KeySuffix = keySuffix; }
public bool HasPromoBeenCompleted(PromoType type) { return(PlayerPrefs.HasKey(m_Factories[type].PrefsKey)); }
public BasePromo(PromoType type) { m_PromoType = type; }