示例#1
0
        public static void IncludeData(MeetingRoomContext meetingRoomContext, MeetingRoomSchedulingContext meetingRoomSchedulingContext)
        {
            Console.WriteLine("Start Migrations...");

            meetingRoomContext.Database.Migrate();

            if (!meetingRoomContext.MeetingRoom.Any())
            {
                Console.WriteLine("Inserting Meeting Room...");

                meetingRoomContext.MeetingRoom.AddRange(
                    new MeetingRommModel {
                    Name = "Las Vegas", Number = 1, CreatedDate = DateTime.Now
                },
                    new MeetingRommModel {
                    Name = "Dalas", Number = 2, CreatedDate = DateTime.Now
                },
                    new MeetingRommModel {
                    Name = "New York", Number = 3, CreatedDate = DateTime.Now
                }
                    );
                meetingRoomContext.SaveChanges();
            }
            else
            {
                Console.WriteLine("Data already exists...");
            }

            if (!meetingRoomSchedulingContext.MeetingRoomScheduling.Any())
            {
                Console.WriteLine("Inserting Meeting Room Scheduling...");

                meetingRoomSchedulingContext.MeetingRoomScheduling.AddRange(
                    new MeetingRoomSchedulingModel {
                    Number = 1, Date = DateTime.Now, Hour = RangeOfHoursEnum.SixOclockPM, CreatedDate = DateTime.Now
                },
                    new MeetingRoomSchedulingModel {
                    Number = 2, Date = DateTime.Now, Hour = RangeOfHoursEnum.SixOclockPM, CreatedDate = DateTime.Now
                },
                    new MeetingRoomSchedulingModel {
                    Number = 3, Date = DateTime.Now, Hour = RangeOfHoursEnum.SixOclockPM, CreatedDate = DateTime.Now
                }
                    );
                meetingRoomSchedulingContext.SaveChanges();
            }
            else
            {
                Console.WriteLine("Data already exists...");
            }
        }
示例#2
0
 public MeetingRoomSchedulingRepository(MeetingRoomSchedulingContext context)
 {
     _context = context;
 }