Example #1
0
    public void InitControls()
    {
        currentStage = new ICOStage(ObjectID);

        int     TotalPurchasedTokens = currentStage.GetAvailableTokens();
        int     AvailableTokens      = currentStage.TotalAvailableTokens - TotalPurchasedTokens;
        Decimal PercentOfTokens      = ((Decimal)TotalPurchasedTokens / (Decimal)currentStage.TotalAvailableTokens) * 100;

        ICOStageName.Text         = currentStage.Name;
        ICOStagePriceLiteral.Text = currentStage.TokenPrice.ToString();
        ICOStageAvailableTokensPercentLiteral.Text = string.Format("<input type='text' class='knob' value='{0}' data-width='125' data-height='125' data-thickness='0.25' data-fgColor='#65a858'>", Math.Round(PercentOfTokens, 0).ToString());
        ICOStageAvailableTokensLiteral.Text        = (currentStage.TotalAvailableTokens - AvailableTokens).ToString();

        TokenImage.ImageUrl = AppSettings.Ethereum.ERC20TokenImageUrl;

        StageStart = currentStage.StartDate;
        StageEnd   = currentStage.EndDate;

        if (StageEnd < AppSettings.ServerTime)
        {
            ICOStageEventLiteral.Text = L1.FINISHED;
            ICOStageItem.Attributes.Add("class", "ICOStage finished");
        }
        else if (StageStart > AppSettings.ServerTime)
        {
            ICOStageTimestamp.Attributes.Add("data-timestamp", StageStart.ToString());
            ICOStageEventLiteral.Text = String.Format("{0} <span class='countdown-placeholder'></span>", U6012.STARTSIN);
            ICOStageItem.Attributes.Add("class", "ICOStage finished ICOtimer");
        }
        else
        {
            ICOStageTimestamp.Attributes.Add("data-timestamp", StageEnd.ToString());
            ICOStageEventLiteral.Text = String.Format("{0} <span class='countdown-placeholder'></span>", U6012.ENDSIN);
            ICOStageItem.Attributes.Add("class", "ICOStage ICOtimer");
        }
    }
Example #2
0
        public IActionResult UploadJsonToDb(int index, int quantity)
        {
            var path  = _appEnvironment.WebRootPath + "\\jsons";
            var files = Directory.GetFiles(path).Where(f => f.Contains(".json")).ToList();

            for (int j = index; j < quantity + index; j++)
            {
                var text = string.Empty;

                if (files.Count > j)
                {
                    text = System.IO.File.ReadAllText(files[j]);
                }
                else
                {
                    break;
                }

                List <JsonFullObject> jsonModels = new List <JsonFullObject>();

                jsonModels = JsonConvert.DeserializeObject <List <JsonFullObject> >(text);

                for (int i = 0; i < jsonModels.Count; i++)
                {
                    switch (jsonModels[i].EventId)
                    {
                    case 1:
                        var gl = new GameLaunch
                        {
                            Date    = jsonModels[i].Date,
                            EventId = jsonModels[i].EventId
                        };

                        _db.GameLaunches.Add(gl);
                        break;

                    case 2:
                        var fgl = new FirstGameLaunch
                        {
                            Date    = jsonModels[i].Date,
                            Gender  = jsonModels[i].Parameters.Gender,
                            Age     = jsonModels[i].Parameters.Age,
                            Country = jsonModels[i].Parameters.Country,
                            EventId = jsonModels[i].EventId
                        };

                        _db.FirstGameLaunches.Add(fgl);
                        break;

                    case 3:
                        var ss = new StageStart
                        {
                            Date    = jsonModels[i].Date,
                            Stage   = jsonModels[i].Parameters.Stage,
                            EventId = jsonModels[i].EventId
                        };

                        _db.StageStarts.Add(ss);
                        break;

                    case 4:
                        var se = new StageEnd
                        {
                            Date    = jsonModels[i].Date,
                            Stage   = jsonModels[i].Parameters.Stage,
                            Win     = jsonModels[i].Parameters.Win,
                            Time    = jsonModels[i].Parameters.Time,
                            Income  = jsonModels[i].Parameters.Income,
                            EventId = jsonModels[i].EventId
                        };

                        _db.StageEnds.Add(se);
                        break;

                    case 5:
                        var ip = new IngamePurchase
                        {
                            Date    = jsonModels[i].Date,
                            Item    = jsonModels[i].Parameters.Item,
                            Price   = jsonModels[i].Parameters.Price,
                            EventId = jsonModels[i].EventId
                        };

                        _db.IngamePurchases.Add(ip);
                        break;

                    case 6:
                        var cp = new CurrencyPurchase
                        {
                            Date    = jsonModels[i].Date,
                            Name    = jsonModels[i].Parameters.Name,
                            Price   = jsonModels[i].Parameters.Price,
                            Income  = jsonModels[i].Parameters.Income,
                            EventId = jsonModels[i].EventId
                        };

                        _db.CurrencyPurchases.Add(cp);
                        break;
                    }
                }
            }

            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }