示例#1
0
        private static void BuildTestData()
        {
            using (var data = new HssTicketingContext())
            {
                var user = new User() { FirstName = "Nicolai", LastName = "Naglestad", UserName = "******", AccessLevel = 1, Password = "******" };
                data.Users.Add(user);
                var user2 = new User() { FirstName = "Ola", LastName = "Nordman", UserName = "******", AccessLevel = 2, Password = "******" };
                data.Users.Add(user2);

                var happening = new Happening() { HappeningName = "Neon Party", Location = "Remmen", MaxParticipants = 100};
                data.Happenings.Add(happening);
                var happening2 = new Happening() { HappeningName = "Test Party", Location = "Fredrikstad", MaxParticipants = 50};
                data.Happenings.Add(happening2);

                var ticket = new Ticket() { Happening = happening, UniqueId = "123456789", Scanned = true, TimeScanned = new DateTime(2015, 11, 12, 15, 25, 00) };
                data.Tickets.Add(ticket);
                var ticket2 = new Ticket() { Happening = happening2, UniqueId = "987654321", Scanned = true, TimeScanned = new DateTime(2015, 11, 12, 17, 25, 00) };
                data.Tickets.Add(ticket2);

                var ticket3 = new Ticket() { Happening = happening, UniqueId = "147258369" };
                data.Tickets.Add(ticket3);
                var ticket4 = new Ticket() { Happening = happening2, UniqueId = "963852741" };
                data.Tickets.Add(ticket4);

                data.SaveChanges();
            }
        }
示例#2
0
        private static void PrintDataBase()
        {
            using (var data = new HssTicketingContext())
            {
                System.Console.WriteLine("Users:");
                foreach (var s in data.Users.ToList())
                {
                    System.Console.WriteLine(s.UserName);
                }
                System.Console.WriteLine("Events:");
                foreach (var s in data.Happenings.ToList())
                {
                    System.Console.WriteLine(s.HappeningName);
                }
                System.Console.WriteLine("Tickets:");
                foreach (var s in data.Tickets.ToList())
                {
                    System.Console.WriteLine(s.TicketId);
                }
            }

            System.Console.ReadLine();
        }