public string GetCurrency(string id) { long idCcy = JsonConvert.DeserializeObject <Int32>(id); ResponseCurrencyData tmp = GetCurrencyDic(); //return JsonConvert.SerializeObject(tmp.CurrencyDic[idCcy]); return(JsonConvert.SerializeObject(DataLayer.Repository.CurrencyDic[idCcy])); }
public Stream GetCurrencies() { ResponseCurrencyData tmp = GetCurrencyDic(); string jsonStr = JsonConvert.SerializeObject(tmp, Formatting.Indented); WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"; return(new MemoryStream(Encoding.UTF8.GetBytes(jsonStr))); }
ResponseCurrencyData GetCurrencyDic() { ResponseCurrencyData result = new ResponseCurrencyData(); try { var currencies = DataLayer.Repository.GetCurrency(null); foreach (var c in currencies) { if (c != null && !String.IsNullOrEmpty(c.ClassName) && QuantLibAdaptor.GetCurrencyInformation(c) ) { //result.CurrencyDic[c.Id] = c; DataFeed.Repository.ccyDic[c.Id] = c; } } //DataLayer.Repository.CurrencyDic = result.CurrencyDic; result.ccyList = currencies; } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } result.Error = new CustomException(); result.Error.Message = ex.Message + ex.StackTrace; } //we read from the database from te table Currencies // assumption is - if ClassName is not null then the rest of the parameters for each currency should be populated for Quantlib // otherwise it was manually added and everything should be coming from the database only return(result); }