Пример #1
0
 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   = "******"
     }
         );
 }
Пример #2
0
 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
     }
         );
 }
Пример #3
0
        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();
            }
        }
Пример #4
0
 public ProductController(BeerStoreContext context)
 {
     db = context;
 }
Пример #5
0
 public UserController(BeerStoreContext context, IWebHostEnvironment appEnvironment)
 {
     db  = context;
     env = appEnvironment;
 }
Пример #6
0
 public HomeController(BeerStoreContext context)
 {
     db = context;
 }
Пример #7
0
 public AuthController(BeerStoreContext context)
 {
     db = context;
 }