Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            byte[] test = null;
            if (HttpContext.Session.TryGetValue("SellVeDecimal", out test))
            {
                ViewBag.sellVe = HttpContext.Session.GetString("SellVeFormat");

                ViewBag.sellVeHigh = HttpContext.Session.GetString("SellVeHighFormat");
            }
            else
            {
                var sellVE = await SellAdServices.SellAdsAboutAmount("VE", "", 2);

                ViewBag.sellVe     = sellVE[0].ToString("C3", CultureInfo.CreateSpecificCulture("es-VE"));
                ViewBag.sellVeHigh = sellVE[1].ToString("C3", CultureInfo.CreateSpecificCulture("es-VE"));

                HttpContext.Session.SetString("SellVeFormat", sellVE[0].ToString("C3", CultureInfo.CreateSpecificCulture("es-VE")));
                HttpContext.Session.SetString("SellVeDecimal", sellVE[0].ToString());

                HttpContext.Session.SetString("SellVeHighFormat", sellVE[1].ToString("C3", CultureInfo.CreateSpecificCulture("es-VE")));
                HttpContext.Session.SetString("SellVeHighDecimal", sellVE[1].ToString());
            }

            return(View());
        }
Exemplo n.º 2
0
        public async Task <JsonResult> Post(string countryCode, string paymentMethod, string currency, decimal gain, bool isColombia)
        {
            var buySP = BuyAdServices.buyAdsAboutAmount(countryCode, paymentMethod, currency, countryCode == "PE" && currency == "USD" ? 2 : 10);

            Decimal sellVe = 1;

            byte[] test = null;
            if (HttpContext.Session.TryGetValue("SellVeDecimal", out test))
            {
                sellVe = decimal.Parse(HttpContext.Session.GetString("SellVeDecimal"));
            }
            else
            {
                var result = await SellAdServices.SellAdsAboutAmount("VE", "", 2);

                sellVe = result[0];
            }

            var rate = decimal.Round((sellVe / buySP), 4);

            var model = new ExchangeModel()
            {
                rateFormat     = isColombia ? decimal.Round(buySP / sellVe, 2).ToString()  : (rate).ToString("C3", CultureInfo.CreateSpecificCulture("es-VE")),
                rateValue      = (isColombia ? buySP / sellVe : rate),
                rateValueGain  = isColombia ? (rate) + gain : (rate) - gain,
                rateFormatGain = isColombia ? decimal.Round((buySP / sellVe) + gain, 2).ToString() : ((rate) - gain).ToString("C3", CultureInfo.CreateSpecificCulture("es-VE"))
            };

            return(Json(model));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Index()
        {
            var sellVE = await SellAdServices.SellAdsAboutAmount("VE", "", 1, 12);

            //Set values to show in the view
            ViewBag.sellVe     = sellVE[0].ToString("C3", CultureInfo.CreateSpecificCulture("es-VE"));
            ViewBag.sellVeHigh = sellVE[1].ToString("C3", CultureInfo.CreateSpecificCulture("es-VE"));


            return(View());
        }
        public async Task <JsonResult> Get(int id)
        {
            try
            {
                var sellVE = await SellAdServices.SellAdsAboutAmount("VE", "", 2, 0);

                return(Json(new { success = true, sellVe = sellVE[0].ToString("C3", CultureInfo.CreateSpecificCulture("es-VE")), sellVeHigh = sellVE[1].ToString("C3", CultureInfo.CreateSpecificCulture("es-VE")) }));
            }
            catch (Exception)
            {
                return(Json(new { success = false, Message = "Ocurrio un error." }));
            }
        }
        public async Task <JsonResult> Post(string countryCode, string paymentMethod, string currency, decimal gain, bool isColombia)
        {
            int quantity = 10;

            if (countryCode == "PE" && currency == "USD")
            {
                quantity = 4;
            }
            else if (countryCode == "DO")
            {
                quantity = 5;
            }


            var buySP = BuyAdServices.buyAdsAboutAmount(countryCode, paymentMethod, currency, quantity);

            decimal sellVe = 1;

            byte[] test = null;
            if (HttpContext.Session.TryGetValue("SellVeDecimal", out test))
            {
                sellVe = decimal.Parse(HttpContext.Session.GetString("SellVeDecimal"));
            }
            else
            {
                var result = await SellAdServices.SellAdsAboutAmount("VE", "", 2, 0);

                sellVe = result[0];
            }

            var rate = decimal.Round((sellVe / buySP), 4);

            var model = new ExchangeModel()
            {
                rateFormat     = (rate).ToString("C3", CultureInfo.CreateSpecificCulture("es-VE")),
                rateValue      = rate,
                rateValueGain  = rate - (rate * gain / 100),
                rateFormatGain = (rate - (rate * gain / 100)).ToString("C3", CultureInfo.CreateSpecificCulture("es-VE"))
            };

            return(Json(model));
        }