Ejemplo n.º 1
0
        public GenelFinansResponse GenelFinans(GenelFinansRequest genelFinansRequest)
        {
            Kullanicilar kullanicilar = _kullanicilarRepository.Find(x => x.KullaniciAdi == genelFinansRequest.KullaniciAdi);
            StreamReader rr           = new StreamReader("D:\\Programlama\\C#_Uygulamalari\\PROJELERİM\\Bitirme\\Bitirme\\Bitirme\\Bitirme\\Dosyalar\\chain.json");
            string       json2        = rr.ReadToEnd();

            rr.Close();
            GenelChainList sorular = JsonConvert.DeserializeObject <GenelChainList>(json2);

            //  var aa=  sorular.chain.SelectMany(x => x.transactions.Where(a => a.receiver.Split("-")[2].Substring(a.receiver.Length-1,1)=="fm")).ToList();
            //  int result1 = sorular.chain.SelectMany(x => x.transactions.Where(yx => yx.receiver == item.Slug)).Sum(x => x.amount);

            foreach (var item in sorular.chain.SelectMany(x => x.transactions.Where(a => a.receiver.Split("-")[2] == kullanicilar.KullaniciAdi)).ToList())
            {
                kullaniciBlogBagisToplam += item.amount;
            }


            HttpClient client2 = new HttpClient();

            client2.BaseAddress = new Uri("https://api.coinbase.com/v2/prices/");
            HttpResponseMessage responseMessage2 = client2.GetAsync("spot?currency=USD").Result;

            responseMessage2.EnsureSuccessStatusCode();
            var        responseBody = responseMessage2.Content.ReadAsStringAsync();
            CoinKurAll emp          = responseMessage2.Content.ReadAsAsync <CoinKurAll>().Result;


            string today = "http://www.tcmb.gov.tr/kurlar/today.xml";

            var xmlDoc = new XmlDocument();

            xmlDoc.Load(today);

            string USD_Alis = xmlDoc.SelectSingleNode("Tarih_Date/Currency[@Kod='USD']/BanknoteBuying").InnerXml;
            //int dolarInt=conv
            float dolarKur = float.Parse(USD_Alis, CultureInfo.InvariantCulture.NumberFormat);
            GenelFinansResponse genelFinansResponse = new GenelFinansResponse();
            Kullanicilar        kullanicilar1       = _kullanicilarRepository.Find(x => x.KullaniciAdi == genelFinansRequest.KullaniciAdi);

            float toplamBagis = (float)Math.Round(kullaniciBlogBagisToplam, 4);

            genelFinansResponse.bBitcoin = toplamBagis;
            genelFinansResponse.bTl      = (float)Math.Round((emp.data.amount * toplamBagis) * dolarKur, 4);
            genelFinansResponse.bDolar   = (float)Math.Round(emp.data.amount * toplamBagis, 4);

            genelFinansResponse.Bitcoin = (float)Math.Round(kullanicilar1.Bakiye, 4);
            genelFinansResponse.Dolar   = (float)Math.Round(emp.data.amount * kullanicilar1.Bakiye, 4);
            genelFinansResponse.Tl      = (float)Math.Round((emp.data.amount * kullanicilar1.Bakiye) * dolarKur, 4);

            genelFinansResponse.sBitcoin = (float)Math.Round(genelFinansResponse.bBitcoin + genelFinansResponse.Bitcoin, 4);
            genelFinansResponse.sDolar   = (float)Math.Round(genelFinansResponse.bDolar + genelFinansResponse.Dolar, 4);
            genelFinansResponse.sTl      = (float)Math.Round(genelFinansResponse.bTl + genelFinansResponse.Tl, 4);


            return(genelFinansResponse);
        }
        public List <Transactions> BagisList(KullaniciAdRequest kullaniciAdRequest)
        {
            Kullanicilar kullanicilar = _kullanicilarRepository.Find(x => x.KullaniciAdi == kullaniciAdRequest.KullaniciAdi);
            StreamReader rr           = new StreamReader("D:\\Programlama\\C#_Uygulamalari\\PROJELERİM\\Bitirme\\Bitirme\\Bitirme\\Bitirme\\Dosyalar\\chain.json");
            string       json2        = rr.ReadToEnd();

            rr.Close();
            GenelChainList sorular = JsonConvert.DeserializeObject <GenelChainList>(json2);
            //  var aa=  sorular.chain.SelectMany(x => x.transactions.Where(a => a.receiver.Split("-")[2].Substring(a.receiver.Length-1,1)=="fm")).ToList();
            //  int result1 = sorular.chain.SelectMany(x => x.transactions.Where(yx => yx.receiver == item.Slug)).Sum(x => x.amount);
            List <Transactions> transactions = new List <Transactions>();

            foreach (var item in sorular.chain.SelectMany(x => x.transactions.Where(a => a.receiver.Split("-")[2] == kullanicilar.KullaniciAdi)).ToList())
            {
                transactions.Add(new Transactions()
                {
                    amount   = item.amount,
                    receiver = item.receiver,
                    sender   = _genelAppService.IsimKisalt(item.sender)
                });
            }


            return(transactions);
        }