public IndexModel(IHttpContextAccessor httpContextAccessor, BarManager.Models.BarManagerContext context, ILogger <IndexModel> logger) { _userId = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); _context = context; _logger = logger; _util = new Util(logger); _dbUtil = new DbUtil(context, logger); }
public IngredientHub(BarManager.Models.BarManagerContext context, ILogger <IngredientHub> logger) { _context = context; _logger = logger; _util = new Util(logger); }
public IndexModel(IHttpContextAccessor httpContextAccessor, BarManager.Models.BarManagerContext context) { _userId = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); Console.WriteLine("User Id for " + httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.Name) + ": " + _userId); _context = context; }
public CreateModel(IHttpContextAccessor httpContextAccessor, BarManager.Models.BarManagerContext context) { _userId = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); _context = context; }
public static void Initialize(BarManagerContext context) { try { var created = context.Database.EnsureCreated(); } catch (Exception e) { Console.WriteLine(e); } // Look for any students. if (context.Recipe.Any() || context.Ingredient.Any()) { return; // DB has been seeded } var recipe = new Recipe { User = "******", Name = "Old Fashioned", Favorite = true, Instructions = "Muddle sugar cube with bitters. Add ice. Pour whiskey over top and stir. Garnish with orange peel and maraschino cherry.", Description = "A classic whiskey cocktail", Rating = 4.5, Price = 6.00M, AddedDate = DateTime.Now, UpdatedDate = DateTime.Now }; context.Recipe.Add(recipe); context.SaveChanges(); var ingredients = new Ingredient[] { new Ingredient { User = "******", Name = "Rye Whiskey", Favorite = true, Owned = true, PurchaseDate = DateTime.Now }, new Ingredient { User = "******", Name = "Angostora Bitters", Favorite = true, Owned = true, PurchaseDate = DateTime.Now }, new Ingredient { User = "******", Name = "Sugar Cube", Favorite = false, Owned = true, PurchaseDate = DateTime.Now }, new Ingredient { User = "******", Name = "Orange Peel", Favorite = false, Owned = true, PurchaseDate = DateTime.Now }, new Ingredient { User = "******", Name = "Maraschino Cherry", Favorite = true, Owned = true, PurchaseDate = DateTime.Now } }; var ingredientIds = new int[ingredients.Length]; foreach (Ingredient i in ingredients) { context.Ingredient.Add(i); } context.SaveChanges(); var recipeIngredients = new RecipeIngredient[] { new RecipeIngredient { User = "******", RecipeId = recipe.RecipeID, IngredientId = ingredients[0].IngredientID, Amount = "2oz", Required = true }, new RecipeIngredient { User = "******", RecipeId = recipe.RecipeID, IngredientId = ingredients[1].IngredientID, Amount = "4 dashes", Required = true }, new RecipeIngredient { User = "******", RecipeId = recipe.RecipeID, IngredientId = ingredients[2].IngredientID, Amount = "1", Required = true }, new RecipeIngredient { User = "******", RecipeId = recipe.RecipeID, IngredientId = ingredients[3].IngredientID, Amount = "1", Required = false }, new RecipeIngredient { User = "******", RecipeId = recipe.RecipeID, IngredientId = ingredients[4].IngredientID, Amount = "1", Required = false }, }; foreach (RecipeIngredient ri in recipeIngredients) { context.RecipeIngredient.Add(ri); } context.SaveChanges(); }