public static void MigrateAndSeed(this KitchenMasterDbContext dbContext) { if (!dbContext.AllMigrationsApplied()) { dbContext.Database.Migrate(); } dbContext.EnureSeeded(); }
public RecipeService(KitchenMasterDbContext dbContext, RecipeRepository recipeRepository, UserRepository userRepository, CurrentUserService currentUser, IMapper mapper) : base(dbContext) { this._recipeRepository = recipeRepository; this._userRepository = userRepository; this._currentUser = currentUser; this._mapper = mapper; }
private static bool AllMigrationsApplied(this KitchenMasterDbContext dbContext) { var applied = dbContext.GetService <IHistoryRepository>() .GetAppliedMigrations() .Select(m => m.MigrationId); var all = dbContext.GetService <IMigrationsAssembly>() .Migrations .Select(m => m.Key); return(!all.Except(applied).Any()); }
public UserMenuService(KitchenMasterDbContext dbContext, CurrentUserService currentUser, RecipeRepository recipeRepository, MenuHistoryRepository menuHistoryRepository, IMapper mapper) : base(dbContext) { this._dbContext = dbContext; this._currentUser = currentUser; this._recipeRepository = recipeRepository; this._menuHistoryRepository = menuHistoryRepository; this._mapper = mapper; }
public AccountConfirmationService( KitchenMasterDbContext dbContext, UserRepository userRepository, UserManager <KmUser> userManager, IConfiguration configuration, IOptions <EmailOptions> options, AccountConfirmationEmailSender emailSender) : base(dbContext) { this.userRepository = userRepository; this.userManager = userManager; this.configuration = configuration; this.emailSender = emailSender; this.options = options.Value; }
private static void EnureSeeded(this KitchenMasterDbContext dbContext) { if (!dbContext.Units.Any()) { using (var transaction = dbContext.Database.BeginTransaction()) { try { var path = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Seeding", "Units.sql"); var sql = File.ReadAllText(path); dbContext.Database.ExecuteSqlRaw(sql); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); } } } }
public UnitRepository(KitchenMasterDbContext dbContext) : base(dbContext) { }
public BaseRepository(KitchenMasterDbContext context) { dbcontext = context; entitySet = context.Set <TEntity>(); }
public MenuHistoryRepository(KitchenMasterDbContext context) : base(context) { }
public IngredientRepository(KitchenMasterDbContext dbContext) : base(dbContext) { }
public IngredientService(KitchenMasterDbContext dbContext, IngredientRepository ingredientRepository) : base(dbContext) { this._ingredientRepository = ingredientRepository; }
public UnitService(KitchenMasterDbContext dbContext, UnitRepository unitRepository) : base(dbContext) { this._unitRepository = unitRepository; }
public UnitOfWorkService(KitchenMasterDbContext dbContext) { this.dbContext = dbContext; }
public RecipeRepository(KitchenMasterDbContext dbContext) : base(dbContext) { }