private static void GenerateUsers(BeerStoreContext context) { context.Users.AddRange( new User { Fullname = "Dima Timcnkko", AvaUrl = "img", Registered = DateTime.Now, Login = "******", Password = "******" }, new User { Fullname = "Tanya Protas", AvaUrl = "img", Registered = DateTime.Now, Login = "******", Password = "******" }, new User { Fullname = "Andrey Goncharenko", AvaUrl = "img", Registered = DateTime.Now, Login = "******", Password = "******" } ); }
private static void GenerateBeers(BeerStoreContext context) { context.Beers.AddRange( new Beer { Name = "Obolonske", Description = "Strong", ImageUrl = "img", Price = 12 }, new Beer { Name = "Cool lager", Description = "Light", ImageUrl = "img", Price = 15 }, new Beer { Name = "Beer mix", Description = "Lemon", ImageUrl = "img", Price = 18 } ); }
public static void Initialize(BeerStoreContext context) { bool isBeers = context.Beers.Any(); bool isUsers = context.Users.Any(); bool anyChanges = false; if (!isBeers) { GenerateBeers(context); anyChanges = true; } if (!isUsers) { GenerateUsers(context); anyChanges = true; } if (anyChanges) { context.SaveChanges(); } }
public ProductController(BeerStoreContext context) { db = context; }
public UserController(BeerStoreContext context, IWebHostEnvironment appEnvironment) { db = context; env = appEnvironment; }
public HomeController(BeerStoreContext context) { db = context; }
public AuthController(BeerStoreContext context) { db = context; }