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); }
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); }
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); }
public static void Initialize(PizzaStoreData.DataAccess.PizzaStoreDBContext database) { Database = database ?? throw new ArgumentNullException(nameof(database)); ingredientRepo = new dbr.IngredientRepository(Database); }
public IngredientController(dbr.IngredientRepository repo) { ingredientRepo = repo; }