示例#1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            PricingCalendarEntry = await _context.PricingCalendarEntries.FirstOrDefaultAsync(m => m.ID == id);

            if (PricingCalendarEntry == null)
            {
                return(NotFound());
            }
            return(Page());
        }
示例#2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            PricingCalendarEntry = await _context.PricingCalendarEntries.FindAsync(id);

            if (PricingCalendarEntry != null)
            {
                _context.PricingCalendarEntries.Remove(PricingCalendarEntry);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
示例#3
0
        public static void Initialize(PricingCalendarContext context)
        {
            context.Database.EnsureCreated();

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

            var entries = new PricingCalendarEntry[]
            {
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-01"), Price = 37.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-02"), Price = 35m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-03"), Price = 32.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-04"), Price = 40m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-05"), Price = 42.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-06"), Price = 35m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-07"), Price = 30m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-08"), Price = 30m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-09"), Price = 32.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-10"), Price = 37.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-11"), Price = 37.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-12"), Price = 35m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-13"), Price = 32.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-14"), Price = 40m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-15"), Price = 42.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-16"), Price = 35m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-17"), Price = 30m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-18"), Price = 30m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-19"), Price = 32.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-20"), Price = 37.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-21"), Price = 37.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-22"), Price = 35m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-23"), Price = 32.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-24"), Price = 40m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-25"), Price = 42.5m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-26"), Price = 35m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-27"), Price = 30m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-28"), Price = 30m
                },
                new PricingCalendarEntry {
                    Date = DateTime.Parse("2020-02-29"), Price = 32.5m
                },
            };

            foreach (PricingCalendarEntry p in entries)
            {
                context.PricingCalendarEntries.Add(p);
            }

            //var rental = new Rental { StartAt = new DateTime(2020, 2, 3, 23, 30, 0), EndAt = new DateTime(2020, 2, 5, 2, 0, 0) };

            //context.Rentals.Add(rental);

            context.SaveChanges();
        }