void Awake()
 {
     stageEnd = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<StageEnd>();
 }
 void Awake()
 {
     stageEnd = GetComponent<StageEnd>();
 }
Example #3
0
 void Awake()
 {
     stageEnd = GetComponent <StageEnd>();
 }
 void Awake()
 {
     stageEnd = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <StageEnd>();
 }
Example #5
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"));
        }