コード例 #1
0
        public static void SeedData(SingularityLimitedPhaseOneTestContext context)
        {
            if (!context.Product.Any())
            {
                var products = new List <Product> {
                    new Product
                    {
                        Id = 1, Name = "Product 101", Description = "Product 101 des", SKU = "#001", Price = 10
                    },
                    new Product
                    {
                        Id = 2, Name = "Product 102", Description = "Product 102 des", SKU = "#002", Price = 20
                    },
                    new Product
                    {
                        Id = 3, Name = "Product 103", Description = "Product 103 des", SKU = "#003", Price = 30
                    },
                    new Product
                    {
                        Id = 4, Name = "Product 104", Description = "Product 104 des", SKU = "#004", Price = 40
                    },
                    new Product
                    {
                        Id = 5, Name = "Product 105", Description = "Product 105 des", SKU = "#005", Price = 50
                    }
                };

                context.Product.AddRange(products);
                context.SaveChanges();
            }
        }
コード例 #2
0
 public UsersController(SingularityLimitedPhaseOneTestContext context, IOptions <AppSettings> appSettings)
 {
     _context     = context;
     _appSettings = appSettings.Value;
 }
コード例 #3
0
 public ProductsController(SingularityLimitedPhaseOneTestContext context)
 {
     _context = context;
 }