public HomeController(AlcoholContext context) { db = context; // добавляем начальные данные if (db.Alcohols.Count() == 0) { Alcohol alc1 = new Alcohol { Brand = "Jack Daniel's", Strength = 40, Volume = 8 }; Alcohol alc2 = new Alcohol { Brand = "Триозерье", Strength = 40, Volume = 4 }; Alcohol alc3 = new Alcohol { Brand = "VishkiCool", Strength = 40, Volume = 8 }; Alcohol alc4 = new Alcohol { Brand = "Fire", Strength = 37, Volume = 7 }; Alcohol alc5 = new Alcohol { Brand = "Aqua", Strength = 40, Volume = 2 }; Alcohol alc6 = new Alcohol { Brand = "Kentuky Jack", Strength = 40, Volume = 8 }; if (!context.Alcohols.Any()) { context.Alcohols.AddRange(alc1, alc2, alc3, alc4, alc5, alc6); context.SaveChanges(); } if (!context.Alco_types.Any()) { context.Alco_types.AddRange( new Alco_type { Type = "Hard", Price = 1000, }, new Alco_type { Type = "Hard", Price = 7000, }, new Alco_type { Type = "Easy", Price = 50, }, new Alco_type { Type = "Hard", Price = 800, }, new Alco_type { Type = "Easy", Price = 250, } ); context.SaveChanges(); } } }
public AlcoholsController(AlcoholContext context, IMapper mapper, IAlcoholRepository repository) { this._context = context; this._mapper = mapper; this._repository = repository; }