public static string GetCurrencyPrefix(CurrencyEnum C) { switch (C) { case CurrencyEnum.AED: return "د.إ.(AED)"; case CurrencyEnum.AUD: return "$(AUD)"; case CurrencyEnum.CAD: return "$(CAD)"; case CurrencyEnum.EUR: return "€(EUR)"; case CurrencyEnum.HKD: return "$(HKD)"; case CurrencyEnum.SGD: return "$(SGD)"; case CurrencyEnum.USD: return "$(USD)"; case CurrencyEnum.GBP: default: return "£(GBP)"; } }
public static ICurrencyConvert GetCurrencyConverter(CurrencyEnum currencyType, IEnumerable<CurrencyExchange> theCurrencies) { ICurrencyConvert strategy = null; string currencyExchangeName = "GBP-"; switch (currencyType) { case CurrencyEnum.GBP: strategy = new PRCCurrencyConverter(CurrencyEnum.GBP, 1); break; case CurrencyEnum.USD: currencyExchangeName += "USD"; strategy = new PRCCurrencyConverter(CurrencyEnum.USD, (decimal)theCurrencies.First(x=>x.CurrencyExchangeName== currencyExchangeName).CurrencyExchangeRate); break; case CurrencyEnum.EUR: currencyExchangeName += "EUR"; strategy = new PRCCurrencyConverter(CurrencyEnum.EUR, (decimal)theCurrencies.First(x => x.CurrencyExchangeName == currencyExchangeName).CurrencyExchangeRate); break; case CurrencyEnum.CAD: currencyExchangeName += "CAD"; strategy = new PRCCurrencyConverter(CurrencyEnum.CAD, (decimal)theCurrencies.First(x => x.CurrencyExchangeName == currencyExchangeName).CurrencyExchangeRate); break; default: strategy = new PRCCurrencyConverter(CurrencyEnum.GBP, 1); break; } return strategy; }
public offer(string id, decimal price, CurrencyEnum currencyId, int categoryId, string typePrefix, string vendor, string model) : this(id, price, currencyId, categoryId) { this.type = "vendor.model"; this.typePrefix = typePrefix; this.vendor = vendor; this.model = model; }
public async Task ManualRefresh(CurrencyEnum selectedCurrency) { currencyInfos = CoinMarketDownloader.GetTop10(selectedCurrency).Result; NewFeed.Invoke(ProduceDataForListViewItems()); if (CurrencyInfoFeed != null) { CurrencyInfoFeed.Invoke(); } await fileSaver.SavaData(currencyInfos); }
private Price(CurrencyEnum currency, double amount) { if (amount < 0) { throw new NegativePriceAmountException(); } Amount = amount; Currency = currency; }
public OtherNonMonetary(string assetName, CurrencyEnum currency, double initialValue, double netBookValue, double estimatedValue, string nonMonetaryName) { AssetName = assetName; Currency = currency; InitialValue = initialValue; NetBookValue = netBookValue; EstimatedValue = estimatedValue; NonMonetaryName = nonMonetaryName; }
public async Task <IActionResult> Get(CurrencyEnum baseCurrency, CurrencyEnum versusCurrency) { var response = await _currencyService.CurrencyToRate(baseCurrency, versusCurrency); if (!response.Success) { return(Conflict(response.Message)); } return(Ok(response.Data)); }
public DataManagement(CurrencyEnum selectedCurrency) { selectedCurrency = selectedCurrency; fileSaver = new CurrencyFileSaver(); currencyInfos = fileSaver.LoadData().Result; minuteCountDown = new Timer(); minuteCountDown.Interval = new TimeSpan(0, 1, 0).TotalMilliseconds; minuteCountDown.Elapsed += new ElapsedEventHandler(timeElapsed); currencyInfos = fileSaver.LoadData().Result; minuteCountDown.Start(); }
public ValueItem CalculateSharesTotal(CurrencyEnum currency = CurrencyEnum.USD) { decimal total = 0m; foreach (var company in _dataProvider.GetCompanies()) { total += _exchangingService.GetValueInCurrency(company.TotalPrice, currency); } return(new ValueItem(currency, total)); }
public override string ToString() { /* * In assignment, left side must be a variable, not constant. * this.type = "Payment"; */ CurrencyEnum currentCurrency = (CurrencyEnum)this.Currency; return(string.Format("{0}: {1}, Tax(%): {2}, Coin: {3}, Valid: {4}", type, this.amount, this.tax, currentCurrency, this.isValid.HasValue && (bool)this.isValid ? string.Format("Yes") : string.Format("No"))); }
public Account(int accId, string name, CurrencyEnum curr) { AccID = accId; Name = name; Currency = curr; LastUpdate = DateTime.Now; Deposited = 0; TradeList = new List <Trade> { }; FilteredTradeList = new List <Trade> { }; }
public Account(int accId, string name, CurrencyEnum curr, DateTime upd, double deposit) { AccID = accId; Name = name; Currency = curr; LastUpdate = upd; Deposited = deposit; TradeList = new List <Trade> { }; FilteredTradeList = new List <Trade> { }; }
/// <summary> /// This will first try and get a cached currency conversion rate, else it will try and get the excange rate from Yahoo, else it will fallback to webservicex.net /// </summary> /// <param name="amount"></param> /// <param name="fromCurrencyCode"></param> /// <param name="roundUp"></param> /// <returns></returns> public static decimal ConvertToZAR(decimal amount, CurrencyEnum fromCurrency) { string fromCurrencyCode = Enum.GetName(typeof(CurrencyEnum), fromCurrency); const string toCurrency = "ZAR"; ObjectCache cache = MemoryCache.Default; string strCacheName = string.Format("EXCHANGERATE_{0}", fromCurrencyCode); if (cache[strCacheName] == null) { ExchangeRate exchangeRate; try { exchangeRate = GetRateExchangeCurrencyConversion(fromCurrencyCode, toCurrency); if (exchangeRate.rate <= 0) { throw new Exception("GetRateExchangeCurrencyConversion returned exchange rate as 0"); } } catch (Exception) { try { // fall back to Yahoo Currency api exchangeRate = GetYahooCurrencyConversion(fromCurrencyCode, toCurrency); if (exchangeRate.rate <= 0) { throw new Exception("GetYahooCurrencyConversion returned exchange rate as 0"); } } catch (Exception) { // fall back to RateExchange service exchangeRate = GetWebserviceXCurrencyConversion(fromCurrencyCode, toCurrency); if (exchangeRate.rate <= 0) { throw new Exception("Critical error - all currency exchange services failed!"); } } } var zarAmound = amount * exchangeRate.rate; if (cache != null) { cache.Set(strCacheName, zarAmound, DateTime.Now.AddMinutes(5)); } } return((decimal)cache[strCacheName]); }
public Car(string assetName, CurrencyEnum currency, double initialValue, double netBookValue, double estimatedValue, string model, int yearRelease) { AssetName = assetName; Currency = currency; InitialValue = initialValue; NetBookValue = netBookValue; EstimatedValue = estimatedValue; Model = model; YearRelease = yearRelease; }
public MainViewModel() { notifyViewModel = new NotifyViewModel(); currentCurrencyEnum = CurrencyEnum.dollars; dataManagement = new DataManagement(currentCurrencyEnum); currenciesPreviewViewModel = new CurrenciesPreviewViewModel(dataManagement); GoToPreviewsCommand = new RelayCommand(GoToPreviews, CanExecuteGoToPreviews); GoToNotifyCommand = new RelayCommand(GoToNotify, CanExecuteGoToNotify); currentContentViewModel = currenciesPreviewViewModel; currenciesPreviewViewModel.ShowMoreAboutCurrency += new CurrenciesPreviewViewModel.SeeMoreAboutCurrencyDelegate(ChangeViewToCurrencyInfo); }
public IList <decimal> Currency(CurrencyEnum currency) { switch (currency) { case CurrencyEnum.Mexico: return(MexicoCurrency()); case CurrencyEnum.Usa: return(UsaCurrency()); default: throw new Exception($"Not valid currency {currency}"); } }
public Office(string assetName, CurrencyEnum currency, double initialValue, double netBookValue, double estimatedValue, string address, int yearBuilding, int inventoryNumber, double size) { AssetName = assetName; Currency = currency; InitialValue = initialValue; NetBookValue = netBookValue; EstimatedValue = estimatedValue; Address = address; YearBuilding = yearBuilding; InventoryNumber = inventoryNumber; Size = size; }
public bool TryAddStock(string ticker, string figi, CurrencyEnum currency, string name, InstrumentTypeEnum type, int lot) { var stock = new Stock { figi = figi, ticker = ticker, currency = currency, type = type, name = name, lot = lot }; return(TryAddStock(stock)); }
public CurrencyListViewItemFeedData(string symbol, string name, decimal marketCap, decimal price, decimal transactionVolume, decimal pricePercentage24, long tokens, DateTime datavalidity, CurrencyEnum evaluatedIn, long marketPair, long totalSupply) { this.symbol = symbol; this.name = name; this.marketCap = marketCap; this.price = price; this.transactionVolume = transactionVolume; this.pricePercentage24 = pricePercentage24; this.tokens = tokens; this.dataValidity = datavalidity; this.evaluatedIn = evaluatedIn; this.marketPair = marketPair; this.totalSupply = totalSupply; }
public void ChangeSelectedCurrency(CurrencyEnum selectedCurrency) { this.selectedCurrency = selectedCurrency; if ((DateTime.Now - ((CurrencyInfo)currencyInfos.FirstOrDefault()).LastTimeUpdated) > new TimeSpan(0, 0, 30)) { if (CurrencyInfoFeed != null) { CurrencyInfoFeed.Invoke(); } NewFeed.Invoke(ProduceDataForListViewItems()); } }
/// <summary> /// Initializes a new instance of the <see cref="Account" /> class. /// </summary> /// <param name="accountId">Unique identifier of the account (required).</param> /// <param name="availableBalance">Current available balance on the account, it is equal to the balance deducted by the exposure (required).</param> /// <param name="balance">Current balance on the account (required).</param> /// <param name="bonusBalance">Current bonus balance on the account; losses will be refunded up to this amount.</param> /// <param name="commissionType">Commission charged by Smarkets on the account.</param> /// <param name="currency">Currency of the account (required).</param> /// <param name="exposure">Current exposure on the account (required).</param> public Account(string accountId = default(string), string availableBalance = default(string), string balance = default(string), string bonusBalance = default(string), string commissionType = default(string), CurrencyEnum currency = default(CurrencyEnum), string exposure = default(string)) { // to ensure "accountId" is required (not null) if (accountId == null) { throw new InvalidDataException("accountId is a required property for Account and cannot be null"); } else { this.AccountId = accountId; } // to ensure "availableBalance" is required (not null) if (availableBalance == null) { throw new InvalidDataException("availableBalance is a required property for Account and cannot be null"); } else { this.AvailableBalance = availableBalance; } // to ensure "balance" is required (not null) if (balance == null) { throw new InvalidDataException("balance is a required property for Account and cannot be null"); } else { this.Balance = balance; } // to ensure "currency" is required (not null) if (currency == null) { throw new InvalidDataException("currency is a required property for Account and cannot be null"); } else { this.Currency = currency; } // to ensure "exposure" is required (not null) if (exposure == null) { throw new InvalidDataException("exposure is a required property for Account and cannot be null"); } else { this.Exposure = exposure; } this.BonusBalance = bonusBalance; this.CommissionType = commissionType; }
/// <summary> /// Initializes a new instance of the <see cref="SalaryAttributes" /> class. /// </summary> /// <param name="description">description (required).</param> /// <param name="currency">currency (required).</param> /// <param name="issueDate">issueDate (required).</param> /// <param name="dueDate">dueDate (required).</param> /// <param name="exchangeRate">exchangeRate.</param> /// <param name="netTotal">netTotal (required).</param> public SalaryAttributes(string description = default(string), CurrencyEnum currency = default(CurrencyEnum), DateTime?issueDate = default(DateTime?), DateTime?dueDate = default(DateTime?), decimal?exchangeRate = default(decimal?), decimal?netTotal = default(decimal?)) { // to ensure "description" is required (not null) if (description == null) { throw new InvalidDataException("description is a required property for SalaryAttributes and cannot be null"); } else { this.Description = description; } // to ensure "currency" is required (not null) if (currency == null) { throw new InvalidDataException("currency is a required property for SalaryAttributes and cannot be null"); } else { this.Currency = currency; } // to ensure "issueDate" is required (not null) if (issueDate == null) { throw new InvalidDataException("issueDate is a required property for SalaryAttributes and cannot be null"); } else { this.IssueDate = issueDate; } // to ensure "dueDate" is required (not null) if (dueDate == null) { throw new InvalidDataException("dueDate is a required property for SalaryAttributes and cannot be null"); } else { this.DueDate = dueDate; } // to ensure "netTotal" is required (not null) if (netTotal == null) { throw new InvalidDataException("netTotal is a required property for SalaryAttributes and cannot be null"); } else { this.NetTotal = netTotal; } this.ExchangeRate = exchangeRate; }
public static async Task <IList <CurrencyInfo> > GetTop10(CurrencyEnum selectedCurrency) { IList <CurrencyInfo> inBitcoinInfo = GetTop10BasedOnCurrency(CurrencyEnum.bitcoin).Result; IList <CurrencyInfo> inUSDInfo = GetTop10BasedOnCurrency(CurrencyEnum.dollars).Result; IList <CurrencyInfo> inEURInfo = GetTop10BasedOnCurrency(CurrencyEnum.euros).Result; foreach (CurrencyInfo currI in inBitcoinInfo) { CurrencyQuote cq = ((CurrencyQuote)inUSDInfo.Where(x => x.Name == currI.Name).FirstOrDefault().Quotes.FirstOrDefault()); CurrencyQuote cq2 = ((CurrencyQuote)inEURInfo.Where(x => x.Name == currI.Name).FirstOrDefault().Quotes.FirstOrDefault()); currI.Quotes.Add(cq); currI.Quotes.Add(cq2); } return(inBitcoinInfo); }
public void RenovateCurrency(CurrencyEnum currency, int number) { if (_currencies.Exists(x => x.currency == currency)) { for (int i = 0; i < _currencies.Count; i++) { if (_currencies[i].currency == currency) { _currencies[i].number = number; break; } } } else { _currencies.Add(new Currency(currency, number)); } }
public static string returnString(CurrencyEnum passedEnum) { string toReturn = ""; switch (passedEnum) { case CurrencyEnum.bitcoin: toReturn = "BTC"; break; case CurrencyEnum.dollars: toReturn = "USD"; break; case CurrencyEnum.euros: toReturn = "EUR"; break; } return(toReturn); }
public async Task <ServiceResponse <CurrencyRatesResponse> > CurrencyToRates(CurrencyEnum baseCurrency) { CurrenciesContainer container = new CurrenciesContainer(); try { container = await GetCurrencies(); } catch (HttpRequestException ex) { return(new ServiceResponse <CurrencyRatesResponse> { Success = false, Message = @"A problem was found in an external HTTP request to https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml, try again" }); } var data = new CurrencyRatesResponse(); data.Base = baseCurrency.ToString(); data.Date = container.Date; var currency1 = container.Currencies.FirstOrDefault(x => x.Name == baseCurrency.ToString()); foreach (var item in Enum.GetValues(typeof(CurrencyEnum))) { var currency2 = container.Currencies.FirstOrDefault(x => x.Name == item.ToString() && x.Name != baseCurrency.ToString() ); if (currency2 != null) { var convertResult = ConvertCurrency(1M, currency1, currency2); data.Rates.Add(currency2.Name, convertResult); } } return(new ServiceResponse <CurrencyRatesResponse> { Success = true, Data = data }); }
public decimal GetValueInCurrency(ValueItem val, CurrencyEnum currency) { if (!_rates.ContainsKey(val.Currency)) { throw new MissingCurrencyRateException(val.Currency); } if (!_rates.ContainsKey(currency)) { throw new MissingCurrencyRateException(currency); } var destRate = _rates[currency]; var srcRate = _rates[val.Currency]; var res = val.Value * destRate / srcRate; return(res); }
public void AddAmount(CurrencyEnum cur, double amount) { var curr = Currencies?.FirstOrDefault(c => c.Currency == cur); if (curr == null) { if (Currencies == null) { Currencies = new List <CurrencyUser>(); } curr = new CurrencyUser(this, amount, cur); Currencies.Add(curr); } else { curr.Amount = curr.Amount += amount; } }
/// <summary> /// Initializes a new instance of the <see cref="DepositBonusConditionsResponseMinDeposit" /> class. /// </summary> /// <param name="amount">amount (required).</param> /// <param name="currency">currency (required).</param> public DepositBonusConditionsResponseMinDeposit(OneOfdepositBonusConditionsResponseMinDepositAmount amount = default(OneOfdepositBonusConditionsResponseMinDepositAmount), CurrencyEnum currency = default(CurrencyEnum)) { // to ensure "amount" is required (not null) if (amount == null) { throw new InvalidDataException("amount is a required property for DepositBonusConditionsResponseMinDeposit and cannot be null"); } else { this.Amount = amount; } // to ensure "currency" is required (not null) if (currency == null) { throw new InvalidDataException("currency is a required property for DepositBonusConditionsResponseMinDeposit and cannot be null"); } else { this.Currency = currency; } }
private static string API_KEY = "ad4f8e0f-66ae-480c-8b2f-0e4acb94320a"; //full public static CurrencyEnum returnEnum(string quoteCurrency) { CurrencyEnum toReturn = CurrencyEnum.dollars; switch (quoteCurrency) { case "USD": toReturn = CurrencyEnum.dollars; break; case "EUR": toReturn = CurrencyEnum.euros; break; case "BTC": toReturn = CurrencyEnum.bitcoin; break; } return(toReturn); }
public void AssignRate(CurrencyEnum currency, decimal rate) { if (rate <= 0) { throw new ArgumentOutOfRangeException("rate", rate, "Positive values only"); } if (BasicCurrency == currency) { throw new ArgumentException("currency", "Basic currency cannot have the excange rate"); } if (_rates.ContainsKey(currency)) { _rates[currency] = rate; } else { _rates.Add(currency, rate); } }
public void RemoveAmount(CurrencyEnum cur, double amount) { var curr = Currencies?.FirstOrDefault(c => c.Currency == cur); if (curr == null) { if (Currencies == null) { Currencies = new List <CurrencyUser>(); } curr = new CurrencyUser(this, 0, cur); RemoveAmount(cur, amount); } if (curr.Amount < amount) { throw new WouldMakeCurrencyNegative(); } curr.Amount = curr.Amount -= amount; }
public static string GetDisplayAmount(string InputAmount, string InputCurrencyCode, string OutputCountryCode,CurrencyEnum? UserCurrency ) { var OutputCurrency = CurrencyLogic.MapCountryCodeToCurrencyEnum(OutputCountryCode); var InputCurrency = CurrencyLogic.MapCurrencyStringToCurrencyEnum(InputCurrencyCode); if (UserCurrency.HasValue) {OutputCurrency = UserCurrency.Value;} decimal InputAmountDec = 0; decimal.TryParse(InputAmount,out InputAmountDec); decimal OutputAmount =InputAmountDec; if (InputCurrency !=OutputCurrency) { OutputAmount = ConvertAmount(InputCurrency, OutputCurrency, InputAmountDec); return $"~{GetCurrencyPrefix(OutputCurrency)}{OutputAmount.ToString("0.00")}"; } return $"{GetCurrencyPrefix(OutputCurrency)}{OutputAmount.ToString("0.00")}"; }
public static string GetDisplayAmount(List<Models.Pledges.PledgeContributors> Inputs, string OutputCountryCode, CurrencyEnum? UserCurrency) { var OutputCurrency = MapCountryCodeToCurrencyEnum(OutputCountryCode); if (UserCurrency.HasValue) { OutputCurrency = UserCurrency.Value; } decimal Total = Inputs.Sum(PC => ConvertAmount(PC.Currency, OutputCurrency, PC.Amount)); if (Inputs.Any(a => a.Currency != OutputCurrency)) return $"~{GetCurrencyPrefix(OutputCurrency)}{Total.ToString("0.00")}"; return $"{GetCurrencyPrefix(OutputCurrency)}{Total.ToString("0.00")}"; }
public static decimal ToCurrency(List<Models.Pledges.PledgeContributors> Inputs,CurrencyEnum OutputCurrency) { return Inputs.Sum(PC => ConvertAmount(PC.Currency,OutputCurrency,PC.Amount)); }
public static decimal ConvertAmount(CurrencyEnum From, CurrencyEnum To,decimal Amount) { //convert input to gbp then to output var InputAmountGBP = Amount / GetCurrencyCoefficient(From); return InputAmountGBP * GetCurrencyCoefficient(To); }
public static decimal ToBase(CurrencyEnum From,decimal amount) => ConvertAmount(From, CurrencyEnum.GBP, amount);
public static decimal GetCurrencyCoefficient(CurrencyEnum C) { switch (C) { case CurrencyEnum.AED: return (decimal)5.57; case CurrencyEnum.AUD: return (decimal)2.18; case CurrencyEnum.CAD: return (decimal)2.04; case CurrencyEnum.EUR: return (decimal)1.35; case CurrencyEnum.HKD: return (decimal)11.76; case CurrencyEnum.SGD: return (decimal)2.17; case CurrencyEnum.USD: return (decimal)1.52; //case CurrencyEnum.GBP: default: return (decimal)1.00; } }