Ejemplo n.º 1
0
        public void SeedFighterLevels(IStarWars3Context context, string path)
        {
            string[] fighters = File.ReadAllLines(path);

            for (int i = 1; i < fighters.Length; i++)
            {
                string[] data = fighters[i]
                                .Split(',')
                                .Select(arg => arg.Replace("\"", string.Empty))
                                .ToArray();

                UnitLevel fighter = new UnitLevel
                {
                    Name            = data[0],
                    Type            = (UnitType)int.Parse(data[1]),
                    Level           = int.Parse(data[2]),
                    Damage          = int.Parse(data[3]),
                    Shield          = int.Parse(data[4]),
                    Armor           = int.Parse(data[5]),
                    Health          = int.Parse(data[6]),
                    Speed           = int.Parse(data[7]),
                    FuelConsumption = int.Parse(data[8]),
                };

                //context.UnitLevels.AddOrUpdate(a =>
                //  new { a.Name, a.Level, ... },
                //  fighter);

                context.UnitLevels.Add(fighter);
            }
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public StarWars3DB(IStarWars3Context starWars3Contect)
        {
            if (starWars3Contect == null)
            {
                throw new ArgumentException("An instance of starWars3Contect is required to use this unit of work.", "starWars3Contect");
            }

            this.starWars3Context = starWars3Contect;
        }
Ejemplo n.º 3
0
        public GenericRepository(IStarWars3Context context)
        {
            if (context == null)
            {
                throw new ArgumentException("An instance of IStarWars3Context is required to use this repository.", "context");
            }

            this.Context = context;
            this.DbSet   = this.Context.Set <T>();
        }
Ejemplo n.º 4
0
        public void SeedPlanets(IStarWars3Context context)
        {
            PlanetTemplate planetTemplate = new PlanetTemplate()
            {
                IsTaken = false,
                Name    = "Tatuin-1",

                Locations = new List <Cell>()
                {
                    new Cell()
                    {
                        row = 2, col = 2
                    },
                    new Cell()
                    {
                        row = 2, col = 3
                    },
                    new Cell()
                    {
                        row = 3, col = 1
                    },
                    new Cell()
                    {
                        row = 3, col = 2
                    },
                    new Cell()
                    {
                        row = 3, col = 3
                    },
                    new Cell()
                    {
                        row = 4, col = 2
                    },
                    new Cell()
                    {
                        row = 4, col = 3
                    },
                },
            };

            context.PlanetTemplates.Add(planetTemplate);
        }