示例#1
0
        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;
 }
示例#3
0
        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;
 }
示例#6
0
 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)
 {
 }
示例#8
0
 public BaseRepository(KitchenMasterDbContext context)
 {
     dbcontext = context;
     entitySet = context.Set <TEntity>();
 }
示例#9
0
 public MenuHistoryRepository(KitchenMasterDbContext context) : base(context)
 {
 }
 public IngredientRepository(KitchenMasterDbContext dbContext)
     : base(dbContext)
 {
 }
 public IngredientService(KitchenMasterDbContext dbContext,
                          IngredientRepository ingredientRepository)
     : base(dbContext)
 {
     this._ingredientRepository = ingredientRepository;
 }
示例#12
0
 public UnitService(KitchenMasterDbContext dbContext,
                    UnitRepository unitRepository)
     : base(dbContext)
 {
     this._unitRepository = unitRepository;
 }
示例#13
0
 public UnitOfWorkService(KitchenMasterDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
 public RecipeRepository(KitchenMasterDbContext dbContext)
     : base(dbContext)
 {
 }