Esempio n. 1
0
 private void AddOneSamuraiWithRelatedData()
 {
     using (var context = new SamuraiContext())
     {
         var samurai = new Samurai
         {
             Name   = "Gandalf",
             Sword  = "Pinnjävel",
             Clan   = "Ringbärarna",
             Quotes = new List <Quote>
             {
                 new Quote
                 {
                     SamuraiQuote = "heeeeeey maakarena",
                     TypeOfQuote  = TypeOfQuote.Cheesy
                 }
             },
             HairCut        = HairCut.Oicho,
             SecretIdentity = new SecretIdentity
             {
                 Name = "Galadriel"
             },
             SamuraiBattle = new List <SamuraiBattle>
             {
                 new SamuraiBattle
                 {
                     Battle = new Battle
                     {
                         Name       = "Slaget om de två tornen",
                         Brutal     = true,
                         StartTime  = DateTime.Now,
                         EndTime    = DateTime.Now.AddDays(1),
                         BattleLogs = new BattleLog
                         {
                             Name         = "Logg om kriget",
                             BattleEvents = new List <BattleEvent>
                             {
                                 new BattleEvent
                                 {
                                     Name        = "Aragon Gör stuff",
                                     Description = "Tävling mellan legolas och gimli",
                                     StartTime   = DateTime.Now,
                                     EndTime     = DateTime.Now.AddDays(1)
                                 },
                                 new BattleEvent
                                 {
                                     Name        = "Gandalf",
                                     Description = "Gandalf får spö av sauroman",
                                     StartTime   = DateTime.Now.AddDays(1),
                                     EndTime     = DateTime.Now.AddDays(2)
                                 }
                             }
                         }
                     }
                 }
             }
         };
         context.Samurais.Add(samurai);
         context.SaveChanges();
     }
 }
Esempio n. 2
0
 private void AddSomeBattles()
 {
     using (var context = new SamuraiContext())
     {
         List <Battle> battles = new List <Battle>
         {
             new Battle
             {
                 Name       = "Slaget om midgård",
                 Brutal     = true,
                 StartTime  = DateTime.Now,
                 EndTime    = DateTime.Now.AddDays(1),
                 BattleLogs = new BattleLog
                 {
                     Name         = "Log of slaget om midgård",
                     BattleEvents = new List <BattleEvent>
                     {
                         new BattleEvent
                         {
                             Name        = "Orcerna anfaller porten",
                             Description = " Orcerna misslyckas med att anfalla porten",
                             StartTime   = DateTime.Now,
                             EndTime     = DateTime.Now.AddDays(1)
                         },
                         new BattleEvent
                         {
                             Name        = "Frodo",
                             Description = "Frodo smyger sig förbi orcerna",
                             StartTime   = DateTime.Now.AddDays(1),
                             EndTime     = DateTime.Now.AddDays(2)
                         }
                     }
                 }
             },
             new Battle
             {
                 Name       = "The hobbit Fight",
                 Brutal     = true,
                 StartTime  = DateTime.Now,
                 EndTime    = DateTime.Now.AddDays(6),
                 BattleLogs = new BattleLog
                 {
                     Name         = "Loggan of the logg",
                     BattleEvents = new List <BattleEvent>
                     {
                         new BattleEvent
                         {
                             Name        = "Legolas hjälper alla",
                             Description = "Legolas hoppar och far, och dödar alla själv",
                             StartTime   = DateTime.Now,
                             EndTime     = DateTime.Now.AddDays(3)
                         },
                         new BattleEvent
                         {
                             Name        = "Gimli",
                             Description = "Gimli är ett litet barn och slår ner en orc",
                             StartTime   = DateTime.Now.AddDays(1),
                             EndTime     = DateTime.Now.AddDays(4)
                         }
                     }
                 }
             }
         };
         context.Battles.AddRange(battles);
         context.SaveChanges();
     }
 }
Esempio n. 3
0
 public DataAccess()
 {
     context = new SamuraiContext();
 }