Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            PromoType promotype = db.PromoTypes.Single(p => p.PromoTypeID == id);

            db.PromoTypes.DeleteObject(promotype);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 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());
     }
 }
Exemplo n.º 4
0
        //
        // 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));
        }
Exemplo n.º 5
0
 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));
 }
Exemplo n.º 6
0
        public ActionResult Create(PromoType promotype)
        {
            if (ModelState.IsValid)
            {
                db.PromoTypes.AddObject(promotype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(promotype));
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
        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";
        }
Exemplo n.º 9
0
        // 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);
            }
        }
Exemplo n.º 10
0
 public PromoFactory(PromoType type, string keySuffix)
 {
     m_Type = type; m_KeySuffix = keySuffix;
 }
Exemplo n.º 11
0
 public bool HasPromoBeenCompleted(PromoType type)
 {
     return(PlayerPrefs.HasKey(m_Factories[type].PrefsKey));
 }
Exemplo n.º 12
0
 public BasePromo(PromoType type)
 {
     m_PromoType = type;
 }