コード例 #1
0
ファイル: PromoFactory.cs プロジェクト: gospella/oop_csu
        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);
        }
コード例 #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"));
        }
コード例 #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());
     }
 }
コード例 #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));
        }
コード例 #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));
 }
コード例 #6
0
        public ActionResult Create(PromoType promotype)
        {
            if (ModelState.IsValid)
            {
                db.PromoTypes.AddObject(promotype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(promotype));
        }
コード例 #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();
        }
コード例 #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";
        }
コード例 #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);
            }
        }
コード例 #10
0
 public PromoFactory(PromoType type, string keySuffix)
 {
     m_Type = type; m_KeySuffix = keySuffix;
 }
コード例 #11
0
 public bool HasPromoBeenCompleted(PromoType type)
 {
     return(PlayerPrefs.HasKey(m_Factories[type].PrefsKey));
 }
コード例 #12
0
ファイル: BasePromo.cs プロジェクト: mikeage/open-brush
 public BasePromo(PromoType type)
 {
     m_PromoType = type;
 }