示例#1
0
        public RepairsController(RepairContext context)
        {
            _context = context;

            if (!context.Repairs.Any())
            {
                _context.AddRange(new List <Repair>
                {
                    new Repair
                    {
                        Requester = new Requester {
                            Name = "John Smith", PhoneNumber = "0675214572", Email = "*****@*****.**"
                        },
                        Asset = new Asset {
                            Location = "West corner of Microsoft Way, Redmond", AssetType = "Street Light"
                        }
                    },
                    new Repair
                    {
                        Requester = new Requester {
                            Name = "Claire Smith", PhoneNumber = "0622486247", Email = "*****@*****.**"
                        },
                        Asset = new Asset {
                            Location = "Intersection of Four Lanes & Cycle Track, Berlin", AssetType = "Generator"
                        }
                    },
                    new Repair
                    {
                        Requester = new Requester {
                            Name = "Luis Vasque", PhoneNumber = "0614756328", Email = "*****@*****.**"
                        },
                        Asset = new Asset {
                            Location = "Out front of central station, The Hague", AssetType = "Switch Box"
                        }
                    }
                });

                _context.SaveChanges();
            }
        }