コード例 #1
0
 public static void InitializeMapper(PizzaStoreDBContext database)
 {
     Database          = database ?? throw new ArgumentNullException(nameof(database));
     inventoryRepo     = new dbr.InventoryJunctionRepository(database);
     ingredientRepo    = new dbr.IngredientRepository(database);
     orderJunctionRepo = new dbr.OrderJunctionRepository(database);
     pizzaRepo         = new dbr.PizzaJunctionRepository(database);
 }
コード例 #2
0
        public void Create(PizzaJunction entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            // Ensure that ingredient exists before trying to create
            //  the junction including it
            IngredientRepository ingredientRepo = new IngredientRepository(Database);

            // GetById will throw an exception if not
            ingredientRepo.GetById(entity.IngredientId);

            // Location / Ingredients are valid. Can successfully create
            //  the inventory junction
            Database.Add(entity);
        }
コード例 #3
0
        public void Create(InventoryJunction entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            // Ensure the Location / Ingredient exist
            //  before trying to create the junction
            // (GetById will throw if not)
            LocationRepository locationRepo = new LocationRepository(Database);

            locationRepo.GetById(entity.LocationId);
            IngredientRepository ingredientRepo = new IngredientRepository(Database);

            ingredientRepo.GetById(entity.IngredientId);

            // Location / Ingredients are valid. Can successfully create
            //  the inventory junction
            Database.Add(entity);
        }
コード例 #4
0
 public static void Initialize(PizzaStoreData.DataAccess.PizzaStoreDBContext database)
 {
     Database       = database ?? throw new ArgumentNullException(nameof(database));
     ingredientRepo = new dbr.IngredientRepository(Database);
 }
コード例 #5
0
 public IngredientController(dbr.IngredientRepository repo)
 {
     ingredientRepo = repo;
 }