コード例 #1
0
        public static void Initialise(MealPlannerContext context)
        {
            context.Database.EnsureCreated();

            // Look for any Menus
            if (context.Menus.Any())
            {
                return; // DB has been seeded
            }
            var fakeCamp = new Camp
            {
                Name = "Fake Camp"
            };

            var straddy = new Camp
            {
                Name = "Stradbroke Cup"
            };

            var camps = new Camp[]
            {
                fakeCamp,
                straddy
            };

            foreach (var camp in camps)
            {
                context.Camps.Add(camp);
            }

            context.SaveChanges();

            var menus = new Menu[]
            {
                new Menu {
                    MenuName = "Tristan's First Menu", StartDate = DateTime.Parse("2020-03-02"), EndDate = DateTime.Parse("2020-03-04"), CampID = fakeCamp.ID
                },
                new Menu {
                    MenuName = "Straddy 2020", StartDate = DateTime.Parse("2020-04-10"), EndDate = DateTime.Parse("2020-04-14"), CampID = straddy.ID
                }
            };

            foreach (var menu in menus)
            {
                context.Menus.Add(menu);
            }

            context.SaveChanges();
        }
コード例 #2
0
 public EditModel(MealPlanner.Data.MealPlannerContext context)
 {
     _context = context;
 }
コード例 #3
0
 public IndexModel(MealPlanner.Data.MealPlannerContext context)
 {
     _context = context;
 }
コード例 #4
0
 public DetailsModel(MealPlanner.Data.MealPlannerContext context)
 {
     _context = context;
 }
コード例 #5
0
 public DeleteModel(MealPlanner.Data.MealPlannerContext context)
 {
     _context = context;
 }
コード例 #6
0
 public MealPlannerRepo(MealPlannerContext context)
 {
     _context = context;
 }