Esempio n. 1
0
        public async void getSummonSessionFromDB()
        {
            int  id;
            bool success = Int32.TryParse(summonSessionID, out id);

            if (success)
            {
                summonSession = await db.getSummonSession(this.GetDatabasePath("Summons.db").AbsolutePath, id);

                calculateRates();
            }
            else
            {
                Toast.MakeText(this, "Invalid ID", ToastLength.Long);
            }
        }
Esempio n. 2
0
        public async void AddSummonToSummonSession()
        {
            if (summonSession != null)
            {
                Summon summon = new Summon();

                //SessionID
                summon.SummonSessionID = summonSession.ID;

                //Scroll Type
                #region scrollType
                //I used this method instead of just getting the index and assigning
                //that because I thought this was a lot more clear. But it is a lot more
                //effort. Also, if I ever added another option above other, that
                //wouldn't work.
                int scrollRadioButtonID = scrollTypeRadioGroup.CheckedRadioButtonId;

                if (mysticScrollRadioButton.Checked)
                {
                    summon.SummonTypeID = 1;
                }
                else if (summoningStonesRadioButton.Checked)
                {
                    summon.SummonTypeID = 2;
                }
                else if (lightDarkScrollRadioButton.Checked)
                {
                    summon.SummonTypeID = 3;
                }
                else if (lengendaryScrollRadioButton.Checked)
                {
                    summon.SummonTypeID = 4;
                }
                //Other
                else
                {
                    summon.SummonTypeID = 5;
                }
                #endregion
                //Star Number
                #region starNumber
                //Unlike above, this is immutable, so I thought an index approach
                //was acceptable
                int  starRadioButtonID       = starNumberRadioGroup.CheckedRadioButtonId;
                View selectedStarRadioButton = starNumberRadioGroup.FindViewById(starRadioButtonID);

                summon.Stars = starNumberRadioGroup.IndexOfChild(selectedStarRadioButton);
                #endregion

                //Name
                if (!String.IsNullOrEmpty(monsterNameEditText.Text))
                {
                    summon.Name = monsterNameEditText.Text;
                }
                else
                {
                    summon.Name = "";
                }

                //Insert
                await db.insertUpdateData <Summon>(summon, this.GetDatabasePath("Summons.db").AbsolutePath);

                //Calculate Summon Rates
                calculateRates();
            }
            else
            {
                if (summonSessionID != null)
                {
                    getSummonSessionFromDB();
                    AddSummonToSummonSession();
                }
                else
                {
                    SummonSession newSummonSession = new SummonSession();
                    newSummonSession.Date = DateTime.Now;
                    await db.insertUpdateData(newSummonSession, this.GetDatabasePath("Summons.db").AbsolutePath);

                    summonSession = newSummonSession;
                    AddSummonToSummonSession();
                }
            }
        }