Example #1
0
    protected void Commit_Click(object sender, EventArgs e)
    {
        IMyLog logUpgrade = MyLog.GetLogger("Upgrade");

        try
        {
            UpdateInfo priceInfo = getHardcodedPriceInfoOrGoBackToPricePage();

            int howManyNumbers = 0;
            int.TryParse(HowManyNumbers.SelectedItem.Value, out howManyNumbers);

            int howManyMessages = 0;
            int.TryParse(HowManyMessages.SelectedItem.Value, out howManyMessages);

            int howManyTopups = 0;
            int.TryParse(HowManyTopups.SelectedItem.Value, out howManyTopups);

            int fullpayment = 0;
            int.TryParse(FullPayment.SelectedItem.Value, out fullpayment);

            logUpgrade.Info("Commit");

            Data_AppUserWallet wal = Data_AppUserWallet.Create(
                sd.LoggedOnUserEmail,
                TitleId.Text,
                priceInfo.Info,
                priceInfo.Type,
                new AmountAndPrice(howManyNumbers, GetPrice(priceInfo.Number)),
                new AmountAndPrice(howManyMessages, GetPrice(priceInfo.Message)),
                new AmountAndPrice(howManyTopups, GetPrice(priceInfo.Month)),
                new AmountAndPrice(1, GetPrice(priceInfo.OneTimeSetup)),
                new AmountAndPrice(fullpayment, GetPrice(priceInfo.FullPayment)));

            string emailBody = wal.GetEmailBody(sd.LoggedOnUserName, sd.LoggedOnUserEmail);

            bool alreadyThere;
            DSSwitch.appWallet().StoreNew(wal, out alreadyThere, logUpgrade);

            EMail.SendGeneralEmail(sd.LoggedOnUserEmail, true, wal.Title, emailBody, new LogForEmailSend(MyLog.GetLogger("Email")));

            showStoredData(wal);
        }
        catch (DataUnavailableException)
        {
            DSSwitch.OnDataUnavailableException(this);
        }
        catch (Exception ex)
        {
            logUpgrade.Debug(ex.Message);
        }
    }