Exemplo n.º 1
0
        public ActionResult OnPostDelete(int id)
        {
            var data = (from i in _context.Ingredient
                        where i.IngredientID == id
                        select i).SingleOrDefault();

            _context.Remove(data);
            _context.SaveChanges();


            return(new EmptyResult());
            //return RedirectToPage(new{id = recipeid});
        }
Exemplo n.º 2
0
        public ActionResult OnPostDelete(int id)
        {
            var data = (from i in _context.Recipe
                        where i.RecipeID == id
                        select i).SingleOrDefault();

            var Ingredient = _context.Ingredient.Where(x => x.RecipeID == id);

            _context.Ingredient.RemoveRange(Ingredient);
            _context.Remove(data);
            _context.SaveChanges();

            return(new EmptyResult());
            //return RedirectToPage();
        }
Exemplo n.º 3
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RecipeContext(
                       serviceProvider.GetRequiredService <DbContextOptions <RecipeContext> >()))
            {
                // Look for any movies.
                if (context.Recipe.Any())
                {
                    return;   // DB has been seeded
                }

                context.Recipe.AddRange(
                    new Recipe
                {
                    Name        = "Carne Asada",
                    CreatedDate = DateTime.Now,
                    Type        = "Mexican",
                    CreatedBy   = "Jorge Luis"
                },

                    new Recipe
                {
                    Name        = "Sukiyaki",
                    CreatedDate = DateTime.Now,
                    Type        = "Japanese",
                    CreatedBy   = "Adriana"
                },

                    new Recipe
                {
                    Name        = "French Toast",
                    CreatedDate = DateTime.Now,
                    Type        = "Breakfast",
                    CreatedBy   = "Jorge Luis"
                }
                    );
                context.SaveChanges();
            }
        }