Esempio n. 1
0
        public async Task <Portafoglio> ScaricaPortafoglio()
        {
            HttpClient client = new HttpClient()
            {
                BaseAddress = new Uri("https://api.etherscan.io/api")
            };

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage risposta = await client.GetAsync("?module=account&action=balance&address=" + Portafoglio.Indirizzo);

            if (risposta.IsSuccessStatusCode)
            {
                String contenuto = await risposta.Content.ReadAsStringAsync();

                var json = Json.Decode(contenuto);

                if (!Decimal.TryParse(json["result"], out decimal quantità))
                {
                    throw new EccezioneApi("Valore non valido");
                }
                quantità /= (decimal)Math.Pow(10, 18); //Il valore restituito è multiplo, lo riporto a valore unitario
                Valuta valuta = _factory.OttieniValuta("ETH");
                Fondo  fondo  = new Fondo(valuta, quantità);
                Portafoglio.Fondo = fondo;
                return(Portafoglio);
            }
            else
            {
                throw new EccezioneApi("EthereumEtherscan(ScaricaPortafoglio()):Errore chiamata API, codice:" + risposta.StatusCode);
            }
        }
Esempio n. 2
0
        public async Task <Portafoglio> ScaricaPortafoglio()
        {
            HttpClient client = new HttpClient
            {
                BaseAddress = new Uri("https://blockexplorer.com/api/addr/")
            };

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage risposta = await client.GetAsync(Portafoglio.Indirizzo + "/balance");

            if (risposta.IsSuccessStatusCode)
            {
                String contenuto = await risposta.Content.ReadAsStringAsync();

                if (!Decimal.TryParse(contenuto, out decimal quantità))
                {
                    throw new EccezioneApi("Valore non valido");
                }
                quantità /= 100000000; //Il valore restituito è in satoshi(0.00000001 BTC), lo riporto a valore unitario
                Valuta valuta = _factory.OttieniValuta("BTC");
                Portafoglio.Fondo = new Fondo(valuta, quantità);
                return(Portafoglio);
            }
            else
            {
                throw new EccezioneApi("BitcoinBlockExplorer(ScaricaPortafoglio()):Errore chiamata API, codice HTTP:" + risposta.StatusCode);
            }
        }
Esempio n. 3
0
        public MainWindow()
        {
            InitializeComponent();
            var doc = new XmlDocument();

            doc.Load(@"http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");

            XmlNodeList nodes = doc.SelectNodes("//*[@currency]");

            if (nodes != null)
            {
                foreach (XmlNode node in nodes)
                {
                    var valuta = new Valuta()
                    {
                        code = node.Attributes["currency"].Value,
                        rate = double.Parse(node.Attributes["rate"].Value, NumberStyles.Any, new CultureInfo("en-Us"))
                    };
                    valutas.Add(valuta);
                }

                valutas.Add(new Valuta {
                    code = "EUR", rate = 1
                });
            }
            comboxleftside.ItemsSource  = valutas;
            comboxrightside.ItemsSource = valutas;
        }
Esempio n. 4
0
        public Player GetPlayer(Players player, Valuta valuta)
        {
            OutfieldPlayer newPlayer = new OutfieldPlayer();

            newPlayer.Id           = player.ID_Player;
            newPlayer.CornerKick   = player.Corner_kick;
            newPlayer.Crossing     = player.Crossing;
            newPlayer.Dribbling    = player.Dribbling;
            newPlayer.Finishing    = player.Finishing;
            newPlayer.FreeKick     = player.Free_kick;
            newPlayer.Heading      = player.Heading;
            newPlayer.Longshot     = player.Longshot;
            newPlayer.LongThrow    = player.Long_throw;
            newPlayer.Marking      = player.Marking;
            newPlayer.PentaltyKick = player.Pentalty_kick;
            newPlayer.Tackling     = player.Tackling;
            newPlayer.Technique    = player.Technique;
            newPlayer.Acceleration = player.Acceleration;
            newPlayer.Age          = player.Age;
            newPlayer.Aggression   = player.Aggression;
            newPlayer.Agility      = player.Agility;
            newPlayer.Anticipation = player.Anticipation;
            newPlayer.Balance      = player.Balance;
            newPlayer.Bravery      = player.Bravery;
            newPlayer.Club         = new ViewModels.Club
            {
                Name     = player.Clubs.ClubName,
                Division = new ViewModels.Division
                {
                    Name   = player.Clubs.Divisions.DivisionName,
                    Nation = player.Clubs.Divisions.Based
                }
            };
            newPlayer.Composure      = player.Composure;
            newPlayer.Concentration  = player.Concentration;
            newPlayer.Decisions      = player.Decisions;
            newPlayer.Determination  = player.Determination;
            newPlayer.FirstTouch     = player.First_touch;
            newPlayer.Height         = player.Hight;
            newPlayer.JumpingReach   = player.Jumping;
            newPlayer.Leadership     = player.Leadership;
            newPlayer.Name           = player.Name;
            newPlayer.Nationality    = player.Nationality;
            newPlayer.NaturalFitness = player.Natural_fitness;
            newPlayer.OffTheBall     = player.Off_the_ball;
            newPlayer.Pace           = player.Pace;
            newPlayer.Passing        = player.Passing;
            newPlayer.Position       = player.Position;
            newPlayer.Positioning    = player.Positioning;
            newPlayer.Stamina        = player.Stamina;
            newPlayer.Strength       = player.Strentgh;
            newPlayer.Teamwork       = player.Teamwork;
            newPlayer.Value          = (int)valuta.Convert(DataCleaner.ConvertValueToNumber(player.Value));
            newPlayer.Vision         = player.Vision;
            newPlayer.Weight         = player.Weight;
            newPlayer.Workrate       = player.Workrate;
            newPlayer.Flair          = player.Flair;

            return(newPlayer);
        }
Esempio n. 5
0
        //private bool isLoading = false;
        //public bool IsLoading
        //{
        //    get { return isLoading; }
        //    set { SetAndNotifyProperty("IsLoading", ref isLoading, value); }
        //}

        /// <summary>
        /// Загружает итоговую информацию о счёте (итоги по платежам и итоги по счёту)
        /// </summary>
        public void CollectInfo()
        {
            if (sfRef == null)
            {
                return;
            }
            sfVal       = repository.GetValutaByKod(SfRef.KodVal);
            postavschik = repository.GetKontrAgent(CommonModule.CommonSettings.OurKontrAgentKod);
            GetOtpravitel();
            platelschik = repository.GetKontrAgent(SfRef.Kpok);
            GetPoluchatel();
            GetResourceOwner();
            postBank = repository.GetBankInfo((int)SfRef.IdDog, repository.OurKgr);
            if (SfRef.StOtpr > 0)
            {
                fromStation = repository.GetRailStation(SfRef.StOtpr);
            }
            if (SfRef.StPol > 0)
            {
                toStation = repository.GetRailStation(SfRef.StPol);
            }
            platBank = repository.GetBankInfo(SfRef.IdDog, SfRef.Kpok);
            dogovor  = repository.GetDogInfo(SfRef.IdDog, false);
            weight   = repository.GetSfWeightInfo(SfRef.IdSf);

            LoadPrils();

            sumOpl = repository.GetSfSumOpl(SfRef.IdSf);

            SelectOkpoData();

            CheckESFN();

            isLoaded = true;
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            double a1, s = 0;

            a1 = Convert.ToDouble(textBox1.Text);

            if (listBox1.Text == "доллар")
            {
                s           = Valuta.ValDollar(a1);
                label1.Text = a1 + " руб " + " = " + Convert.ToString(s) + " долларов";
            }
            else
            if (listBox1.Text == "евро")
            {
                s           = Valuta.ValEvro(a1);
                label1.Text = a1 + " руб " + " = " + Convert.ToString(s) + " евро";
            }


            else
            if (listBox1.Text == "фунт")
            {
                s           = Valuta.ValFynt(a1);
                label1.Text = a1 + " руб " + " = " + Convert.ToString(s) + " фунтов";
            }
            else
            {
                s           = a1;
                label1.Text = a1 + " руб " + " = " + Convert.ToString(s) + " грн";
            }
        }
Esempio n. 7
0
 public Goods()
 {
     _code   = new Code();
     _name   = new Name();
     _cost   = new Cost();
     _valuta = new Valuta();
 }
Esempio n. 8
0
        public async Task <List <Fondo> > ScaricaFondi()
        {
            try
            {
                _fondi = new List <Fondo>();
                BinanceClient binanceClient = new BinanceClient(_apiClient);
                AccountInfo   ris           = await binanceClient.GetAccountInfo();

                Binance.API.Csharp.Client.Models.Market.Balance[] risArray = ris.Balances.ToArray();

                for (int i = 0; i < risArray.Length; i++)
                {
                    if (risArray[i].Free != 0 || risArray[i].Locked != 0)
                    {
                        decimal quantità = Convert.ToDecimal(risArray[i].Free + risArray[i].Locked);
                        Valuta  valuta   = _factory.OttieniValuta(risArray[i].Asset);
                        Fondo   fondo    = new Fondo(valuta, quantità);
                        _fondi.Add(fondo);
                    }
                }
            }
            catch (Exception e)
            {
                throw new EccezioneApi("BinanceExchange(ScaricaFondi()): Errore durante il collegamento: " + e.Message);
            }
            return(_fondi);
        }
Esempio n. 9
0
        // GET: UlazSkidanje
        public ActionResult Index(int id, int?UlazSkidanjeId)
        {
            Ulaz u = s.Ulaz.Include("Klasa").Single(x => x.Id == id);

            ViewData["u"] = u;
            List <UlazSkidanje> us = s.UlazSkidanje.Where(x => x.UlazId == id).ToList();

            ViewData["us"] = us;
            int BrojSkinutihBalvana = 0;

            foreach (UlazSkidanje x in us)
            {
                BrojSkinutihBalvana += x.SkinutoBalvana;
            }
            ViewData["BrojSkinutihBalvana"] = BrojSkinutihBalvana;

            if (UlazSkidanjeId != null)
            {
                UlazSkidanje use = s.UlazSkidanje.Single(x => x.Id == UlazSkidanjeId);
                ViewData["use"] = use;
            }
            else
            {
                UlazSkidanje use = new UlazSkidanje();
                ViewData["use"] = use;
            }

            Valuta v = s.Valuta.SingleOrDefault();

            ViewData["v"] = v;

            return(View());
        }
Esempio n. 10
0
    private Geld MaakGeldValutaGelijk(Geld g, Geld m)
    {
        switch (g.ToString().Substring(0, 1))
        {
        case "E":
            m.ConvertTo(Valuta.Euro);
            ValutaLinks = Valuta.Euro;
            break;

        case "G":
            m.ConvertTo(Valuta.Gulden);
            ValutaLinks = Valuta.Gulden;

            break;

        case "D":
            m.ConvertTo(Valuta.Dukaat);
            ValutaLinks = Valuta.Dukaat;

            break;

        case "F":
            m.ConvertTo(Valuta.Florijn);
            ValutaLinks = Valuta.Florijn;

            break;
        }

        return(m);
    }
        // GET: UlazSkidanjeProizvod
        public ActionResult Index(int id, string Block)
        {
            UlazSkidanje                us  = s.UlazSkidanje.Single(x => x.Id == id);
            Ulaz                        u   = s.Ulaz.Single(x => x.Id == us.UlazId);
            List <Proizvod>             p   = s.Proizvod.ToList();
            List <UlazSkidanjeProizvod> usp = s.UlazSkidanjeProizvod.Include("Proizvod").Include("Proizvod.Klasa").Where(x => x.UlazSkidanjeId == id).ToList();

            double PlaniranoM3 = 0, OstvarenoM3 = 0;

            foreach (UlazSkidanjeProizvod x in usp)
            {
                PlaniranoM3 += ((x.Proizvod.Duzina / 100) * (x.Proizvod.Sirina / 100) * (x.Proizvod.Visina / 100) * x.PlaniranaKolicina);
                OstvarenoM3 += ((x.Proizvod.Duzina / 100) * (x.Proizvod.Sirina / 100) * (x.Proizvod.Visina / 100) * x.Kolicina);
            }
            ViewData["PlaniranoM3"] = PlaniranoM3;
            ViewData["OstvarenoM3"] = OstvarenoM3;

            ViewData["us"]  = us;
            ViewData["u"]   = u;
            ViewData["p"]   = p;
            ViewData["usp"] = usp;
            Valuta v = s.Valuta.SingleOrDefault();

            ViewData["v"]     = v;
            ViewData["Block"] = Block;
            return(View());
        }
        public Valuta Izbrisi(object id)
        {
            Valuta postojecaValuta  = _bankaKontekst.Valute.Find(id);
            var    rezultatBrisanja = _bankaKontekst.Valute.Remove(postojecaValuta).Entity;

            return(rezultatBrisanja);
        }
Esempio n. 13
0
 public Valuta GetValuteByCode(string valutaCode)
 {
     //функция загружает нужную валюту с сайта
     try
     {
         var       xml    = client.DownloadString("http://www.cbr.ru/scripts/XML_valFull.asp");
         XDocument xdoc   = XDocument.Parse(xml);
         var       el     = xdoc.Element("Valuta").Elements("Item").Where(x => x.Attribute("ID").Value == valutaCode);
         Valuta    valuta = context.Valutas.Where(v => v.Code == valutaCode).First();
         if (valuta == null)
         {
             valuta = new Valuta
             {
                 Code          = valutaCode,
                 Name          = el.Elements("Name").FirstOrDefault().Value,
                 EngName       = el.Elements("EngName").FirstOrDefault().Value,
                 Nominal       = Convert.ToInt32(el.Elements("Nominal").FirstOrDefault().Value),
                 ISO_Num_Code  = Convert.ToInt32(el.Elements("ISO_Num_Code").FirstOrDefault().Value),
                 ISO_Char_Code = el.Elements("ISO_Char_Code").FirstOrDefault().Value
             };
             context.Entry(valuta).State = EntityState.Added;
             context.SaveChanges();
         }
         return(valuta);
     }
     catch
     {
         return(null);
     }
 }
Esempio n. 14
0
 public ValCurs LoadCursFromCbrByDate(DateTime dateTime, string valutaCode)
 {
     try
     {
         var       xml    = client.DownloadString("http://www.cbr.ru/scripts/XML_daily.asp?date_req=" + dateTime.ToString("dd.MM.yyyy"));
         XDocument xdoc   = XDocument.Parse(xml);
         var       el     = xdoc.Element("ValCurs").Elements("Valute").Where(x => x.Attribute("ID").Value == valutaCode);
         Valuta    valuta = GetValuteByCode(valutaCode);
         if (valuta != null)
         {
             ValCurs valCurs = new ValCurs
             {
                 CursDate = dateTime,
                 Value    = Convert.ToDecimal(el.Elements("Value").FirstOrDefault().Value),
                 ValutaId = valuta.Id
             };
             context.Entry(valCurs).State = EntityState.Added;
             context.SaveChanges();
             return(valCurs);
         }
         return(null);
     }
     catch
     {
         return(null);
     }
 }
Esempio n. 15
0
        public void TestCastValutaToDouble()
        {
            var    valuta = new Valuta(Muntsoort.Euro, 10.45M);
            double result = valuta;

            Assert.AreEqual(10.45D, result);
        }
Esempio n. 16
0
        public async Task <IHttpActionResult> PutValuta(int id, Valuta valuta)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != valuta.Id)
            {
                return(BadRequest());
            }

            db.Entry(valuta).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ValutaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 17
0
        public void TestPlusPlusOperator()
        {
            var valuta = new Valuta(Muntsoort.Euro, 1.00M);

            valuta++;
            Assert.AreEqual(2.00M, valuta.Bedrag);
        }
Esempio n. 18
0
    public void ConvertTo(Valuta muntsoort)
    {
        ConvertToGulden();
        ConvertFromGulden(muntsoort);

        Muntsoort = muntsoort;
    }
Esempio n. 19
0
        public void TestIsGelijkAanOperator()
        {
            var valuta1 = new Valuta(Muntsoort.Euro, 400);
            var valuta2 = new Valuta(Muntsoort.Euro, 400);

            Assert.IsTrue(valuta1 == valuta2);
        }
Esempio n. 20
0
 public Serves(int pCost, Valuta pV, Srochnost pSr, DateTime pD)
 {
     cost               = pCost;
     Валюта             = pV;
     Срочность          = pSr;
     Дата_подачи_заявки = pD;
 }
Esempio n. 21
0
        static SuperChatData()
        {
            var euroCurrency = ISOCurrencies.AllCurrencies.First(x => x.Symbol == new CurrencySymbol("€"));

            KNOWN_CURRENCY = euroCurrency;

            var redValuta = new Valuta(euroCurrency, 100);

            RED = new(Color.FromRgb(208, 0, 0), Color.FromRgb(230, 33, 23), Color.FromRgb(255, 255, 255), redValuta);

            var vanityValuta = new Valuta(euroCurrency, 50);

            VANITY = new(Color.FromRgb(194, 24, 91), Color.FromRgb(233, 30, 99), Color.FromRgb(255, 255, 255), vanityValuta);

            var amberValuta = new Valuta(euroCurrency, 20);

            AMBER = new(Color.FromRgb(230, 81, 0), Color.FromRgb(245, 124, 0), Color.FromRgb(255, 255, 255), amberValuta);

            var saffronValuta = new Valuta(euroCurrency, 10);

            SAFFRON = new(Color.FromRgb(255, 179, 0), Color.FromRgb(255, 202, 40), Color.FromRgb(0, 0, 0), saffronValuta);

            var carribbeanValuta = new Valuta(euroCurrency, 5);

            CARRIBEAN = new(Color.FromRgb(0, 191, 165), Color.FromRgb(29, 233, 182), Color.FromRgb(0, 0, 0), carribbeanValuta);

            var cyanValuta = new Valuta(euroCurrency, 2);

            CYAN = new(Color.FromRgb(0, 184, 212), Color.FromRgb(0, 229, 255), Color.FromRgb(0, 0, 0), cyanValuta);

            var denimValuta = new Valuta(euroCurrency, 1);

            DENIM = new(Color.FromRgb(21, 101, 192), default, Color.FromRgb(255, 255, 255), denimValuta);
Esempio n. 22
0
        public Valuta GetValutaById(string kode)
        {
            string sqlCommand = "SELECT TOP 1 * FROM m_val WHERE kode = @kode";

            using (SqlCommand cmd = General.GetCommand(sqlCommand))
            {
                cmd.Parameters.Add("@kode", SqlDbType.VarChar, 10).Value = kode;
                cmd.CommandType = CommandType.Text;

                using (SqlDataAdapter sdAdapter = new SqlDataAdapter(cmd))
                {
                    DataSet ds = new DataSet();
                    sdAdapter.Fill(ds, "m_val");

                    Valuta valuta = new Valuta();
                    foreach (DataRow dr in ds.Tables["m_val"].Rows)
                    {
                        valuta.kode    = dr["kode"] as string;
                        valuta.nm      = dr["nm"] as string;
                        valuta.statusx = dr["statusx"] as string;
                    }

                    return(valuta);
                }
            }
        }
Esempio n. 23
0
        public void GetValuteFromXml()
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(List <Valuta>));
            TextReader    reader       = new StreamReader(@"C:/Users/Antonio/Desktop/valute.xml");
            object        obj          = deserializer.Deserialize(reader);
            var           valute       = (List <Valuta>)obj;

            foreach (var valuta in valute)
            {
                Valuta ids = _context.Valute.Find(valuta.ValutaId);

                if (ids == null)
                {
                    valuta.DatumAzuriranja = DateTime.Now;
                    _context.Add(valuta);
                }
                else
                {
                    ids.ValutaId        = valuta.ValutaId;
                    ids.KorisnikId      = valuta.KorisnikId;
                    ids.Naziv           = valuta.Naziv;
                    ids.Tecaj           = valuta.Tecaj;
                    ids.SlikaValute     = valuta.SlikaValute;
                    ids.AktivnoOd       = valuta.AktivnoOd;
                    ids.AktivnoDo       = valuta.AktivnoDo;
                    ids.DatumAzuriranja = valuta.DatumAzuriranja;

                    _context.Update(ids);
                }
                _context.SaveChanges();
            }
            reader.Close();
        }
Esempio n. 24
0
        public async Task <List <Fondo> > ScaricaFondi()
        {
            _fondi = new List <Fondo>();
            //L'implementazione delle API utilizzata non è asincrona quindi la rendo asincrona inserendola in un Task
            await Task.Run(() =>
            {
                try
                {
                    var risArray = _apiClient.GetBalances().ToArray();

                    for (int i = 0; i < risArray.Length; i++)
                    {
                        if (risArray[i].Amount != 0)
                        {
                            decimal quantità = Convert.ToDecimal(risArray[i].Amount);
                            Valuta valuta    = _factory.OttieniValuta(risArray[i].Currency);
                            Fondo fondo      = new Fondo(valuta, quantità);
                            _fondi.Add(fondo);
                        }
                    }
                }
                catch (Exception e)
                {
                    throw new EccezioneApi("BitfinexExchange(ScaricaFondi()): Errore durante il collegamento: " + e.Message);
                }
            });

            return(_fondi);
        }
        public Valuta Izmeni(Valuta obj)
        {
            var izmenjenaValuta = _bankaKontekst.Valute.Attach(obj).Entity;

            _bankaKontekst.Entry(obj).State = EntityState.Modified;

            return(izmenjenaValuta);
        }
Esempio n. 26
0
        public void TestIsGelijkAanNietGelijkOperator()
        {
            var  valuta1 = new Valuta(Muntsoort.Euro, 400);
            var  valuta2 = new Valuta(Muntsoort.Euro, 300);
            bool result  = valuta1 == valuta2 ? false : true;

            Assert.IsTrue(result);
        }
Esempio n. 27
0
        public void TestPlusPlusAlsEerstDifficultOperator()
        {
            var    valuta = new Valuta(Muntsoort.Euro, 1.00M);
            Valuta result = ++valuta;

            Assert.AreEqual(2.00M, valuta.Bedrag);
            Assert.AreEqual(2.00M, result.Bedrag);
        }
Esempio n. 28
0
        public void Maak_EUR3_25()
        {
            Valuta geld = new Valuta(3.25M, Muntsoort.Euro);

            string tekst = geld.ToString();

            Assert.AreEqual("EUR 3,25", tekst);
        }
Esempio n. 29
0
        public void TestKeerOperatorValuta()
        {
            var    valuta = new Valuta(Muntsoort.Euro, 400);
            Valuta result = valuta * 2.5D;

            Assert.AreEqual(1000M, result.Bedrag);
            Assert.AreEqual(Muntsoort.Euro, result.Type);
        }
Esempio n. 30
0
        public void TestCastDoubleToValuta()
        {
            double bedrag   = 10.45D;
            var    expected = new Valuta(Muntsoort.Euro, 10.45M);
            Valuta result   = bedrag;

            Assert.AreEqual(expected, result);
        }