Beispiel #1
0
        public static async Task CreateCustomerAsync()
        {
            Write("First name: ");
            var firstName = ReadLine();

            Write("Last name: ");
            var lastName = ReadLine();

            var customer = new Customer
            {
                FirstName = firstName,
                LastName  = lastName
            };

            WriteLine($"Creation of \n{customer}");

            using var context = new CegidDbContext();
            context.Add(customer);
            await context.SaveChangesAsync();
        }
Beispiel #2
0
 public static async Task CreateRoomsAsync()
 {
     using var context = new CegidDbContext();
     if (await context.Rooms.AnyAsync())
     {
         WriteLine("Already created.");
         return;
     }
     for (int floor = 0; floor < 6; floor++)
     {
         for (int n = 0; n < 10; n++)
         {
             var room = new Room
             {
                 Number = floor * 100 + n,
                 Floor  = floor
             };
             context.Add(room);
         }
     }
     await context.SaveChangesAsync();
 }