Ejemplo n.º 1
0
        public static void Seed(IServiceProvider serviceProvider)
        {
            #region Room
            RoomRepository roomRepository =
                serviceProvider.GetRequiredService <RoomRepository>();

            if (!roomRepository.GetAllRooms().Any())
            {
                roomRepository.AddRange(DbInitializer.GetRooms());
            }


            #endregion

            #region RoomPrices

            RoomPricesRepository roomPricesRepository =
                serviceProvider.GetRequiredService <RoomPricesRepository>();

            if (!roomPricesRepository.GetAllRoomPrices().Any())
            {
                roomPricesRepository.AddRange(DbInitializer.getRoomPrices());
            }

            #endregion

            #region MealPlan

            MealPlanRepository mealPlanRepository =
                serviceProvider.GetRequiredService <MealPlanRepository>();

            if (!mealPlanRepository.GetAllMealPlans().Any())
            {
                mealPlanRepository.AddRange(DbInitializer.getMealPlans());
            }

            #endregion

            #region MealPlanPrices

            MealPlanPricesRepository mealPlanPricesRepository =
                serviceProvider.GetRequiredService <MealPlanPricesRepository>();

            if (!mealPlanPricesRepository.GetAllMealPlansPrices().Any())
            {
                mealPlanPricesRepository.AddRange(DbInitializer.getMealPlanPrices());
            }

            #endregion
        }