Upload project.

This commit is contained in:
StevenJW
2020-06-07 22:36:12 +01:00
parent 0df30b8f36
commit 5829fb5504
170 changed files with 31989 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using ThAmCo.Catering.Data;
namespace ThAmCo.Venues.Data
{
public class CateringDbContext : DbContext
{
public DbSet<Menu> Menus { get; set; }
public DbSet<FoodBooking> FoodBookings { get; set; }
private readonly IHostingEnvironment _hostEnv;
public CateringDbContext(DbContextOptions<CateringDbContext> options,
IHostingEnvironment env) : base(options)
{
_hostEnv = env;
}
protected override void OnConfiguring(DbContextOptionsBuilder builder)
{
base.OnConfiguring(builder);
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.HasDefaultSchema("thamco.catering");
builder.Entity<Menu>()
.HasKey(m => m.Id);
builder.Entity<FoodBooking>()
.HasKey(f => f.Id);
builder.Entity<Menu>()
.HasMany(f => f.FoodBookings)
.WithOne(m => m.Menu)
.HasForeignKey(m => m.Id);
if (_hostEnv != null && _hostEnv.IsDevelopment())
{
builder.Entity<Menu>()
.HasData(
new Menu { Id = 1, Price = 8.50, Items = "Chicken Pate, Chicken Roast, Chicken Cake" },
new Menu { Id = 2, Price = 7.50, Items = "Toast, Cheese On Toast, Jam on Toast" },
new Menu { Id = 3, Price = 9, Items = "Mac and Cheese, Alan's Special, Cheesecake" }
);
}
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ThAmCo.Catering.Data
{
public class FoodBooking
{
public int Id { get; set; }
public int MenuId { get; set; }
public Menu Menu { get; set; }
public string Notes { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Catering.Data
{
public class Menu
{
public int Id { get; set; }
public string Items { get; set; }
public double Price { get; set; }
public List<FoodBooking> FoodBookings { get; set; }
}
}