コード例 #1
0
        //Singleton
        public static MuskeetContext GetContext()
        {
            if (_context == null)
            {
                _context = new MuskeetContext {
                    Users = new List <User> {
                        new User {
                            Id = 1, UserName = "******", City = "Kiev", PostalCode = "152-12", Email = "*****@*****.**", Country = "Ukraine"
                        },

                        new User {
                            Id = 2, UserName = "******", City = "Odessa", PostalCode = "153-13", Email = "*****@*****.**", Country = "Ukraine"
                        }
                    },

                    Appointments = new List <Appointment> {
                        new Appointment {
                            AppointmentId = 1, UserName = "******", TradeMark = "BMV", CompanyName = "BestCars", Date = DateTime.Now
                        }
                    },

                    CarWorkShops = new List <CarWorkShop> {
                        new CarWorkShop {
                            CompanyId  = 1, CompanyName = "BestCars",
                            TradeMarks = new List <TradeMark> {
                                new TradeMark {
                                    TradeMarkId = 1, TradeMarkTittle = "Tesla", CarWorkShopId = 1
                                },
                                new TradeMark {
                                    TradeMarkId = 2, TradeMarkTittle = "BMV", CarWorkShopId = 1
                                }
                            }, City = "Kiev", PostalCode = "152-12", Country = "Ukraine"
                        },

                        new CarWorkShop {
                            CompanyId  = 2, CompanyName = "GoodCars",
                            TradeMarks = new List <TradeMark> {
                                new TradeMark {
                                    TradeMarkId = 1, TradeMarkTittle = "Tesla", CarWorkShopId = 2
                                },
                                new TradeMark {
                                    TradeMarkId = 3, TradeMarkTittle = "Audi", CarWorkShopId = 2
                                }
                            }, City = "Odessa", PostalCode = "153-13", Country = "Ukraine"
                        },

                        new CarWorkShop {
                            CompanyId  = 3, CompanyName = "FunMech",
                            TradeMarks = new List <TradeMark> {
                                new TradeMark {
                                    TradeMarkId = 4, TradeMarkTittle = "Nissan", CarWorkShopId = 3
                                }
                            }, City = "Odessa", PostalCode = "153-13", Country = "Ukraine"
                        }
                    }
                };
            }

            return(_context);
        }
コード例 #2
0
 //Singleton
 public static MuskeetContext GetContextJson()
 {
     if (_context == null)
     {
         _context = new MuskeetContext();
         SeedUsers();
         SeedCarWorkShops();
         SeedAppointments();
     }
     return(_context);
 }