private void showStoredData(Data_AppUserWallet wal) { PriceAndText price = wal.CalucateCost(); TitleId.Text = wal.Title; userName.Text = sd.LoggedOnUserName; InfoText.Text = wal.DisplayLinesAsHTML(); CalcInfo.Text = price.Explained; commitTextDiv.Visible = true; CalcInfoDiv.Visible = true; alterStep1DivVisibility(false, null, 0, 0, 0, 0); CalcInfoDiv.Visible = true; CommitDiv.Visible = false; PaymentInstruction.Visible = true; paypalAmount.Text = String.Format("{0:0.00} USD", price.FinalPrice); paypalLink.HRef = String.Format("https://PayPal.me/NiceAPI/{0:0.00}usd", price.FinalPrice); try { BitcoinPrice.BitcoinPriceInfos currentPrice = BitcoinPrice.PriceFromGecko(); btcAmount.Text = String.Format("{0:0.00000} BTC", price.FinalPrice / currentPrice.btc.PriceInUSD); bchAmount.Text = String.Format("{0:0.00000} BCH", price.FinalPrice / currentPrice.bch.PriceInUSD); } catch { } }
public static void Go(IMyLog log, QuestionOption it) { DSSwitch.appWallet().RetrieveAll( delegate(Data_AppUserWallet w1) { Console.WriteLine(); Console.WriteLine(w1.RequestedType.ToString()); Console.WriteLine(w1.Title); Console.WriteLine(w1.Email); foreach (var l1 in w1.DisplayLines) { Console.WriteLine(l1); } Console.WriteLine(w1.Setup.ToString("Setup")); Console.WriteLine(w1.Messages.ToString("Messages")); Console.WriteLine(w1.Month.ToString("Month")); Console.WriteLine(w1.Numbers.ToString("Numbers")); Console.WriteLine(); PriceAndText pt = w1.CalucateCost(); Console.WriteLine(pt.Explained); Console.WriteLine(pt.FinalPrice); }, log); }
public static PriceAndText CalucateCost(this Data_AppUserWallet appUserWallet) { PriceAndText ret = new PriceAndText(); List <string> left = new List <string>(); List <string> rigt = new List <string>(); if ((appUserWallet.Numbers != null) && (appUserWallet.Numbers.Amount != 0)) { left.Add(String.Format("{0:####} Registered Numbers * $ {1:0.00}", appUserWallet.Numbers.Amount, appUserWallet.Numbers.Price)); rigt.Add((appUserWallet.Numbers.Amount * appUserWallet.Numbers.Price).rigtStr()); ret.FinalPrice += appUserWallet.Numbers.Amount * appUserWallet.Numbers.Price; } if ((appUserWallet.Messages != null) && (appUserWallet.Messages.Amount != 0)) { left.Add(String.Format("{0:####} Messages * $ {1:0.00}", appUserWallet.Messages.Amount, appUserWallet.Messages.Price)); rigt.Add((appUserWallet.Messages.Amount * appUserWallet.Messages.Price).rigtStr()); ret.FinalPrice += appUserWallet.Messages.Amount * appUserWallet.Messages.Price; } if ((appUserWallet.Month != null) && (appUserWallet.Month.Amount != 0)) { left.Add(String.Format("{0:##} Month * $ {1:0.00}", appUserWallet.Month.Amount, appUserWallet.Month.Price)); rigt.Add((appUserWallet.Month.Amount * appUserWallet.Month.Price).rigtStr()); ret.FinalPrice += appUserWallet.Month.Amount * appUserWallet.Month.Price; } if ((appUserWallet.Setup != null) && (appUserWallet.Setup.Price != 0)) { left.Add(String.Format("$ {0:0.00} Setup Fee", appUserWallet.Setup.Price)); rigt.Add((appUserWallet.Setup.Price).rigtStr()); ret.FinalPrice += appUserWallet.Setup.Price; } if ((appUserWallet.FullPayment != null) && ((appUserWallet.FullPayment.Amount * appUserWallet.FullPayment.Price) != 0)) { left.Add(String.Format("$ {0:0.00} Payment", appUserWallet.FullPayment.Amount * appUserWallet.FullPayment.Price)); rigt.Add((appUserWallet.FullPayment.Amount * appUserWallet.FullPayment.Price).rigtStr()); ret.FinalPrice += appUserWallet.FullPayment.Amount * appUserWallet.FullPayment.Price; } // make left same length int maxLen = 0; foreach (string l1 in left) { if (l1.Length > maxLen) { maxLen = l1.Length; } } for (int i = 0; i < left.Count; i++) { ret.Explained += left[i].PadRight(maxLen + 1) + rigt[i] + "\n"; } ret.Explained += "".PadRight(maxLen + 1 + rigt[0].Length, '-') + "\n"; ret.Explained += "TOTAL".PadRight(maxLen + 1); ret.Explained += ret.FinalPrice.rigtStr(); return(ret); }