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

            // Look for any students.
            if (context.Deliveries.Any())
            {
                return;                   // DB has been seeded
            }

            var deliveries = new List <Delivery>();


            var tuesdays  = GetDatesByDayOfWeek(2018, DayOfWeek.Tuesday);
            var thursdays = GetDatesByDayOfWeek(2018, DayOfWeek.Thursday);

            foreach (var day in tuesdays)
            {
                deliveries.Add(new Delivery {
                    Date = day, Status = FacturationWebSite.Models.Enum.DeliveryStatus.Pending
                });
            }

            foreach (var day in thursdays)
            {
                deliveries.Add(new Delivery {
                    Date = day, Status = FacturationWebSite.Models.Enum.DeliveryStatus.Pending
                });
            }


            foreach (Delivery d in deliveries)
            {
                context.Deliveries.Add(d);
            }
            context.SaveChanges();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Folivi95/MvcApp
        public static void Main(string[] args)
        {
            IWebHost host = CreateWebHostBuilder(args).Build();

            using (IServiceScope scope = host.Services.CreateScope())
            {
                IServiceProvider services = scope.ServiceProvider;

                try
                {
                    MvcAppContext context = services.GetRequiredService <MvcAppContext>();
                    context.Database.Migrate();
                    SeedData.InitializeData(services);
                }
                catch (Exception ex)
                {
                    ILogger <Program> logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "There was an error seeding the database");
                    throw;
                }
            }

            host.Run();
        }
コード例 #3
0
 public EmployeesController(MvcAppContext mvcAppContext)
 {
     this._context = mvcAppContext;
 }
コード例 #4
0
 public HomeController(MvcAppContext context)
 {
     _context = context;
 }
コード例 #5
0
 public InvoiceLineController(MvcAppContext context)
 {
     _context = context;
 }
コード例 #6
0
 public BarcodeController(MvcAppContext context)
 {
     _context = context;
 }
コード例 #7
0
ファイル: MusicController.cs プロジェクト: dvorachek/WebApp
 public MusicController(MvcAppContext context)
 {
     _context = context;
 }
コード例 #8
0
 public PeopleController(MvcAppContext context)
 {
     _context = context;
 }
コード例 #9
0
 public DepartmentsController(MvcAppContext mvcAppContext)
 {
     _context = mvcAppContext;
 }
コード例 #10
0
 public CustomerPriceController(MvcAppContext context)
 {
     _context = context;
 }
コード例 #11
0
 public DeliveryController(MvcAppContext context)
 {
     _context = context;
 }
コード例 #12
0
 public MoviesController(MvcAppContext context)
 {
     _context = context;
 }
コード例 #13
0
 public ProductController(MvcAppContext context)
 {
     _context = context;
 }