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

261
.gitignore vendored Normal file
View File

@ -0,0 +1,261 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

View File

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ThAmCo.Catering.Data;
using ThAmCo.Venues.Data;
namespace ThAmCo.Catering.Controllers
{
public class BookingsController
{
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
private readonly CateringDbContext _context;
public ValuesController(CateringDbContext context)
{
_context = context;
}
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<Menu>> Get()
{
return _context.Menus.ToArray();
}
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
var menu = _context.Menus.FirstOrDefault(f => f.Id == id);
if (menu != null)
{
return Ok(menu);
}
return NotFound();
}
// POST api/values/
//Gives the function the menuid it wants to book.
[HttpPost]
public IActionResult Post([FromBody] int id)
{
if (_context.Menus.Any(m => m.Id == id))
{
FoodBooking fb = new FoodBooking
{
MenuId = id,
//Notes = notes,
};
var updatedFB = _context.Add(fb);
_context.SaveChangesAsync();
return Ok(updatedFB);
}
return BadRequest("MenuID was not found.");
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}
}

View File

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ThAmCo.Catering.Data;
using ThAmCo.Venues.Data;
namespace ThAmCo.Catering.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
private readonly CateringDbContext _context;
public ValuesController(CateringDbContext context)
{
_context = context;
}
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<Menu>> Get()
{
return _context.Menus.ToArray();
}
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
var menu = _context.Menus.FirstOrDefault(f => f.Id == id);
if (menu != null)
{
return Ok(menu);
}
return NotFound();
}
// POST api/values/
//Gives the function the menuid it wants to book.
[HttpPost]
public IActionResult Post([FromBody] int id)
{
if (_context.Menus.Any(m => m.Id == id))
{
FoodBooking fb = new FoodBooking
{
MenuId = id,
//Notes = notes,
};
var updatedFB = _context.Add(fb);
_context.SaveChangesAsync();
return Ok(updatedFB);
}
return BadRequest("MenuID was not found.");
}
// PUT api/values/5
[HttpPut("{id}")]
public IActionResult Put([Bind("Items,Price")] Menu food)
{
//If menu exists, edit the current entry.
if (_context.Menus.Any(m => m.Id == food.Id) && ModelState.IsValid)
{
var menu = _context.Menus.First(m => m.Id == food.Id);
_context.Update(menu);
_context.SaveChangesAsync();
return Ok(menu);
}
//If menu doesn't exist, make a current entry.
else if (ModelState.IsValid)
{
_context.Add(food);
_context.SaveChangesAsync();
return Ok();
}
return NotFound();
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

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; }
}
}

View File

@ -0,0 +1,68 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ThAmCo.Venues.Data;
namespace ThAmCo.Catering.Migrations
{
[DbContext(typeof(CateringDbContext))]
[Migration("20181204120817_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("thamco.catering")
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("ThAmCo.Catering.Data.FoodBooking", b =>
{
b.Property<int>("Id");
b.Property<int>("MenuId");
b.Property<string>("Notes");
b.HasKey("Id");
b.ToTable("FoodBookings");
});
modelBuilder.Entity("ThAmCo.Catering.Data.Menu", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Items");
b.Property<double>("Price");
b.HasKey("Id");
b.ToTable("Menus");
b.HasData(
new { Id = 1, Items = "Chicken Pate, Chicken Roast, Chicken Cake", Price = 8.5 },
new { Id = 2, Items = "Toast, Cheese On Toast, Jam on Toast", Price = 7.5 },
new { Id = 3, Items = "Mac and Cheese, Alan's Special, Cheesecake", Price = 9.0 }
);
});
modelBuilder.Entity("ThAmCo.Catering.Data.FoodBooking", b =>
{
b.HasOne("ThAmCo.Catering.Data.Menu", "Menu")
.WithMany("FoodBookings")
.HasForeignKey("Id")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,79 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ThAmCo.Catering.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "thamco.catering");
migrationBuilder.CreateTable(
name: "Menus",
schema: "thamco.catering",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Items = table.Column<string>(nullable: true),
Price = table.Column<double>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Menus", x => x.Id);
});
migrationBuilder.CreateTable(
name: "FoodBookings",
schema: "thamco.catering",
columns: table => new
{
Id = table.Column<int>(nullable: false),
MenuId = table.Column<int>(nullable: false),
Notes = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_FoodBookings", x => x.Id);
table.ForeignKey(
name: "FK_FoodBookings_Menus_Id",
column: x => x.Id,
principalSchema: "thamco.catering",
principalTable: "Menus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
schema: "thamco.catering",
table: "Menus",
columns: new[] { "Id", "Items", "Price" },
values: new object[] { 1, "Chicken Pate, Chicken Roast, Chicken Cake", 8.5 });
migrationBuilder.InsertData(
schema: "thamco.catering",
table: "Menus",
columns: new[] { "Id", "Items", "Price" },
values: new object[] { 2, "Toast, Cheese On Toast, Jam on Toast", 7.5 });
migrationBuilder.InsertData(
schema: "thamco.catering",
table: "Menus",
columns: new[] { "Id", "Items", "Price" },
values: new object[] { 3, "Mac and Cheese, Alan's Special, Cheesecake", 9.0 });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "FoodBookings",
schema: "thamco.catering");
migrationBuilder.DropTable(
name: "Menus",
schema: "thamco.catering");
}
}
}

View File

@ -0,0 +1,66 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ThAmCo.Venues.Data;
namespace ThAmCo.Catering.Migrations
{
[DbContext(typeof(CateringDbContext))]
partial class CateringDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("thamco.catering")
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("ThAmCo.Catering.Data.FoodBooking", b =>
{
b.Property<int>("Id");
b.Property<int>("MenuId");
b.Property<string>("Notes");
b.HasKey("Id");
b.ToTable("FoodBookings");
});
modelBuilder.Entity("ThAmCo.Catering.Data.Menu", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Items");
b.Property<double>("Price");
b.HasKey("Id");
b.ToTable("Menus");
b.HasData(
new { Id = 1, Items = "Chicken Pate, Chicken Roast, Chicken Cake", Price = 8.5 },
new { Id = 2, Items = "Toast, Cheese On Toast, Jam on Toast", Price = 7.5 },
new { Id = 3, Items = "Mac and Cheese, Alan's Special, Cheesecake", Price = 9.0 }
);
});
modelBuilder.Entity("ThAmCo.Catering.Data.FoodBooking", b =>
{
b.HasOne("ThAmCo.Catering.Data.Menu", "Menu")
.WithMany("FoodBookings")
.HasForeignKey("Id")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using ThAmCo.Venues.Data;
namespace ThAmCo.Catering
{
public class Program
{
public static void Main(string[] args)
{
var host = CreateWebHostBuilder(args).Build();
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
var env = services.GetRequiredService<IHostingEnvironment>();
var context = services.GetRequiredService<CateringDbContext>();
if (env.IsDevelopment())
{
context.Database.EnsureDeleted();
}
context.Database.Migrate();
}
host.Run();
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}

View File

@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:32824",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ThAmCo.Catering": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using ThAmCo.Venues.Data;
namespace ThAmCo.Catering
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddDbContext<CateringDbContext>(options =>
{
var cs = Configuration.GetConnectionString("CateringSqlConnection");
options.UseSqlServer(cs);
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
}
}
}

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"ConnectionStrings": {
"CateringSqlConnection": "Server=(localdb)\\mssqllocaldb;Database=Catering;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,190 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using ThAmCo.Events.Data;
using ThAmCo.Events.Models;
namespace ThAmCo.Events.Controllers
{
public class CustomersController : Controller
{
private readonly EventsDbContext _context;
public CustomersController(EventsDbContext context)
{
_context = context;
}
// GET: Customers
public async Task<IActionResult> Index()
{
return View(await _context.Customers.Where(c => c.IsDeleted == false).ToListAsync());
}
// GET: Customers/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
var customer = await _context.Customers
.FirstOrDefaultAsync(m => m.Id == id);
customer.Bookings = _context.Guests.Include(m => m.Event).Where(m => m.CustomerId == id).ToList();
if (customer == null)
{
return NotFound();
}
return View(customer);
}
// GET: Customers/Create
public IActionResult Create()
{
ViewData["EventLists"] = new SelectList(_context.Events, "Id", "Title");
return View();
}
// POST: Customers/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Surname,FirstName,Email,InitialEvent")] CustomerCreateModel customerCreate)
{
Customer customer = null;
GuestBooking guestBooking = null;
if (ModelState.IsValid)
{
customer = new Customer
{
Surname = customerCreate.Surname,
FirstName = customerCreate.FirstName,
Email = customerCreate.Email
};
var customerContext = _context.Add(customer);
int custID = customerContext.Entity.Id;
//A booking is created at the same time as a customer.
guestBooking = new GuestBooking
{
CustomerId = custID,
EventId = customerCreate.InitialEvent,
Attended = true
};
_context.Add(guestBooking);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(customer);
}
// GET: Customers/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}
var customer = await _context.Customers.FindAsync(id);
if (customer == null)
{
return NotFound();
}
return View(customer);
}
// POST: Customers/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Surname,FirstName,Email")] Customer customer)
{
if (id != customer.Id)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(customer);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!CustomerExists(customer.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(customer);
}
// GET: Customers/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}
var customer = await _context.Customers
.FirstOrDefaultAsync(m => m.Id == id);
if (customer == null)
{
return NotFound();
}
return View(customer);
}
// POST: Customers/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var customer = await _context.Customers.FindAsync(id);
customer.IsDeleted = true;
_context.Customers.Update(customer);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
[HttpPost, ActionName("AnonDelete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AnonDeleteConfirmed(int id)
{
var customer = await _context.Customers.FindAsync(id);
customer.FirstName = "[Redacted]";
customer.Surname = "[Redacted]";
customer.Email = "[Redacted]";
customer.IsDeleted = true;
_context.Customers.Update(customer);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
private bool CustomerExists(int id)
{
return _context.Customers.Any(e => e.Id == id);
}
}
}

View File

@ -0,0 +1,605 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using ThAmCo.Events.Data;
using ThAmCo.Events.Models;
using System.Net.Http;
using System.Diagnostics;
using ThAmCo.Events.Models.ViewModels.Events;
using ThAmCo.Events.Models.Dto;
namespace ThAmCo.Events.Views
{
public class EventsController : Controller
{
private readonly EventsDbContext _context;
public EventsController(EventsDbContext context)
{
_context = context;
}
// GET: Events
public async Task<IActionResult> Index()
{
var @event = await _context.Events.Include(e => e.Bookings).Include(s => s.Staffings).ThenInclude(s => s.Staff).Where(e => e.IsDeleted == false).ToListAsync();
return View(@event);
}
// GET: Events/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
var @event = await _context.Events
.FirstOrDefaultAsync(m => m.Id == id);
//Get both bookings and staffings from the database so pass to the view, so it can show the guests and staff for that event.
@event.Bookings = await _context.Guests.Include(m => m.Customer).Where(m => m.EventId == id).ToListAsync();
@event.Staffings = await _context.Staffing.Include(m => m.Staff).Where(m => m.EventId == id).ToListAsync();
if (@event == null)
{
return NotFound();
}
ReservationDto reservation = null;
//Get the reservation information for the event, if it exists.
HttpClient client = new HttpClient
{
BaseAddress = new Uri("http://localhost:23652/")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.GetAsync("api/reservations/" + @event.VenueReference);
if (response.IsSuccessStatusCode)
{
reservation = await response.Content.ReadAsAsync<ReservationDto>();
}
else
{
Debug.WriteLine("Index received a bad response from the web service.");
}
var edm = new EventDetailsModel
{
Id = @event.Id,
Title = @event.Title,
Date = @event.Date,
Duration = @event.Duration,
TypeId = @event.TypeId,
Bookings = @event.Bookings,
Reservation = reservation,
FoodReference = @event.FoodReference,
Staffing = @event.Staffings
};
return View(edm);
}
// GET: Events/Create
public async Task<IActionResult> Create()
{
//For this code, AJAX calls can be used, along with regular HTTP redirects.
//It depends on whether the programmer wants the client or the server to make the call to the web service.
//This isn't a live action effecting the user interface, so it can be done either way.
//This code works and returns the correct things, however the ViewBag doesn't have the correct ID.
/*var eventTypes = new List<EventTypeDto>().AsEnumerable();
HttpClient client = new HttpClient
{
BaseAddress = new Uri("http://localhost:23652/")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.GetAsync("api/eventtypes");
if (response.IsSuccessStatusCode)
{
eventTypes = await response.Content.ReadAsAsync<IEnumerable<EventTypeDto>>();
}
else
{
Debug.WriteLine("Index received a bad response from the web service.");
}
ViewData["EventLists"] = new SelectList(eventTypes, "TypeId", "Title");*/
return View();
}
// POST: Events/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Title,Date,Duration,TypeId")] Event @event)
{
if (ModelState.IsValid)
{
_context.Add(@event);
await _context.SaveChangesAsync();
//Return to the newly created Details page of the event.
return RedirectToAction(nameof(Details), new { id = @event.Id });
}
return View(@event);
}
// GET: Events/SelectVenue
public async Task<IActionResult> SelectVenue(int id)
{
if (ModelState.IsValid)
{
var @event = _context.Events.FirstOrDefaultAsync(e => e.Id == id).Result;
//Check if event exists.
if (@event.Id != 0)
{
var venues = new List<VenueDto>().AsEnumerable();
//For the Selection of the Venue, it could all be handled within one page, however it's loaded on page load.
//AJAX could be used here also, however loading from the server is also fine.
//Get list of the available venues from the web service.
HttpClient client = new HttpClient
{
BaseAddress = new Uri("http://localhost:23652/")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.GetAsync("api/Availability?eventType=" + @event.TypeId + "&beginDate=" + @event.Date.ToString("MM/dd/yyyy") + "&endDate=" + @event.Date.ToString("MM/dd/yyyy"));
if (response.IsSuccessStatusCode)
{
venues = await response.Content.ReadAsAsync<IEnumerable<VenueDto>>();
}
else
{
Debug.WriteLine("Index received a bad response from the web service.");
}
SelectVenueModel svm = new SelectVenueModel
{
Id = id,
Venues = venues.ToList()
};
return View(@svm);
}
}
return RedirectToAction(nameof(Details), new { id = id });
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> CreateReservation([Bind("Id,VenueDate,VenueCode")] EventCreateReservationModel @event)
{
if (ModelState.IsValid)
{
//Add reservation (call add api)
//Needs redirect afterwards so AJAX doesn't need to be used to call here.
HttpClient client = new HttpClient()
{
BaseAddress = new Uri("http://localhost:23652/")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
var reservation = new ReservationCreateDto
{
EventDate = @event.VenueDate,
VenueCode = @event.VenueCode,
StaffId = "Test"
};
HttpResponseMessage response = await client.PostAsJsonAsync("api/reservations", reservation);
//Add the venue reference to the database.
var eventContext = await _context.Events.Include(m => m.Bookings).FirstOrDefaultAsync(e => e.Id == @event.Id);
var originalEvent = eventContext;
eventContext.VenueReference = @event.VenueCode + @event.VenueDate.ToString("yyyyMMdd");
_context.Entry(originalEvent).CurrentValues.SetValues(eventContext);
_context.SaveChanges();
return RedirectToAction(nameof(Details), new { id = @event.Id });
}
return View(@event);
}
public async Task<IActionResult> FreeReservation(int id)
{
var eventContext = await _context.Events.FirstOrDefaultAsync(e => e.Id == id);
if (eventContext.Id != 0)
{
//Request that the reservation called is deleted by the web service.
HttpClient client = new HttpClient()
{
BaseAddress = new Uri("http://localhost:23652/")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.DeleteAsync("api/reservations/" + eventContext.VenueReference);
if (response.IsSuccessStatusCode)
{
//Save this change to local database.
var editedEventContext = eventContext;
editedEventContext.VenueReference = null;
_context.Entry(eventContext).CurrentValues.SetValues(editedEventContext);
_context.SaveChanges();
return RedirectToAction(nameof(Details), new { id = id });
}
else
{
Debug.WriteLine("Index Delete Error.");
}
}
return RedirectToAction(nameof(Details), new { id = id });
}
// GET: Events/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}
var @event = await _context.Events.FindAsync(id);
if (@event == null)
{
return NotFound();
}
return View(@event);
}
// POST: Events/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Title,Duration")] EventEditModel @event)
{
var eventContext = await _context.Events.FirstOrDefaultAsync(m => m.Id == id);
eventContext.Title = @event.Title;
eventContext.Duration = @event.Duration;
if (id != @event.Id)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(eventContext);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!EventExists(@event.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(@event);
}
//Register attendance for customer at event
public async Task<IActionResult> RegisterAttendance([Bind("EventId,CustomerId,Attending")] EventRegisterAttendanceModel @event)
{
//Change attendance for a customer at an event (toggle)
if (@event.CustomerId != 0 && @event.EventId != 0)
{
if (_context.Guests.Any(g => g.EventId == @event.EventId && g.CustomerId == @event.CustomerId))
{
var booking = await _context.Guests.FirstOrDefaultAsync(g => g.EventId == @event.EventId && g.CustomerId == @event.CustomerId);
booking.Attended = !booking.Attended;
_context.Update(booking);
await _context.SaveChangesAsync();
}
}
return RedirectToAction(nameof(Details), new { id = @event.EventId });
}
// GET: Events/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}
var @event = await _context.Events
.FirstOrDefaultAsync(m => m.Id == id);
if (@event == null)
{
return NotFound();
}
return View(@event);
}
// POST: Events/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
//Change the event to deleted.
var @event = await _context.Events.FindAsync(id);
if (@event != null)
{
//Ask web api to delete the reservation that the event used to hold.
HttpClient client = new HttpClient()
{
BaseAddress = new Uri("http://localhost:23652/")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.DeleteAsync("api/reservations/" + @event.VenueReference);
//Soft deletion is done by having a boolean value in the object, true being deleted and false being not deleted.
//Other ways of doing this could be nullable values, such as dates, such that not null values are not deleted, and null values are deleted.
//Using dates is useful if you want to un-delete a lot of data at once from a certain time.
//If successful, soft delete event.
@event.IsDeleted = true;
@event.VenueReference = null;
_context.Events.Update(@event);
/*Guest bookings can be deleted if required.
var guestBookings = await _context.Guests.Where(g => g.EventId == id).ToListAsync();
_context.Guests.RemoveRange(guestBookings);*/
//Hard delete staffings.
var staffings = await _context.Staffing.Where(s => s.EventId == id).ToListAsync();
_context.Staffing.RemoveRange(staffings);
await _context.SaveChangesAsync();
}
return RedirectToAction(nameof(Index));
}
private bool EventExists(int id)
{
return _context.Events.Any(e => e.Id == id);
}
//Removes a Customer from an Event.
// POST: Events/RemoveCustomer/5
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> RemoveCustomer(int id, [Bind("CustomerId,EventId")] GuestBooking guestBooking)
{
if (id != guestBooking.EventId)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Remove(guestBooking);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
throw;
}
return RedirectToAction(nameof(Details), new { id });
}
return RedirectToAction(nameof(Details));
}
public async Task<IActionResult> RemoveStaff(int id, [Bind("StaffId,EventId")] Staffing staffing)
{
if (id != staffing.EventId)
{
return NotFound();
}
if (ModelState.IsValid && staffing.EventId != 0 && staffing.StaffId != 0)
{
try
{
_context.Remove(staffing);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
throw;
}
return RedirectToAction(nameof(Details), new { id = id });
}
return RedirectToAction(nameof(Details));
}
public async Task<IActionResult> AddCustomer(int id)
{
//Get customers that dont exist in current event.
var guests = await _context.Guests.Include(g => g.Customer).Where(g => g.EventId == id).Select(c => c.Customer).ToListAsync();
var customers = await _context.Customers.ToListAsync();
//This seems to be the simplest way to go about it in LINQ.
//Excludes data in the current set.
var result = await _context.Customers.Except(guests).ToListAsync();
EventAddCustomerModel eacm = new EventAddCustomerModel
{
EventId = id,
Customer = result
};
return View(eacm);
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AddCustomer([Bind("CustomerId,EventId")] GuestBooking guestBooking)
{
if (ModelState.IsValid)
{
guestBooking.Customer = _context.Customers.First(c => c.Id == guestBooking.CustomerId);
guestBooking.Event = _context.Events.First(e => e.Id == guestBooking.EventId);
_context.Add(guestBooking);
await _context.SaveChangesAsync();
//Return to the newly created Details page of the event.
return RedirectToAction(nameof(Details), new { id = guestBooking.EventId });
}
return RedirectToAction(nameof(Details));
}
public async Task<IActionResult> AddStaff(int id)
{
var staff = await _context.Staffing.Include(g => g.Staff).Where(g => g.EventId == id).Select(c => c.Staff).ToListAsync();
//Also uses the except function in LINQ.
var result = await _context.Staff.Except(staff).ToListAsync();
EventAddStaffModel eacm = new EventAddStaffModel
{
EventId = id,
Staff = result
};
return View(eacm);
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AddStaff([Bind("StaffId,EventId")] Staffing staffing)
{
if (ModelState.IsValid)
{
staffing.Staff = _context.Staff.First(s => s.Id == staffing.StaffId);
staffing.Event = _context.Events.First(e => e.Id == staffing.EventId);
_context.Add(staffing);
await _context.SaveChangesAsync();
//Return to the newly created Details page of the event.
return RedirectToAction(nameof(Details), new { id = staffing.EventId });
}
return RedirectToAction(nameof(Details));
}
public async Task<IActionResult> AddMenu(int id)
{
if (EventExists(id))
{
//Get menu back from api.
HttpClient client = new HttpClient()
{
BaseAddress = new Uri("http://localhost:32824")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.GetAsync("api/values");
if (response.IsSuccessStatusCode)
{
var menus = response.Content.ReadAsAsync<IEnumerable<MenuDTO>>().Result.ToList();
EventAddMenuModel eamm = new EventAddMenuModel
{
EventId = id,
Menus = menus
};
return View(eamm);
}
else
{
Debug.WriteLine("API GET Error.");
}
}
return RedirectToAction(nameof(Details), new { id = id });
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AddMenu(int EventID, int MenuID)
{
if (EventExists(EventID))
{
//Add the menu reference to database.
var @event = _context.Events.First(e => e.Id == EventID);
@event.FoodReference = MenuID;
_context.Update(@event);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Details), new { id = EventID });
}
return NotFound();
}
public IActionResult FindVenue()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> FindVenueResults([Bind("EventType,StartDate,EndDate")] EventFindVenueModel search)
{
if (ModelState.IsValid)
{
//Return all venues that satify the constraints.
//AJAX could be used here if it was loading on the same page, however different pages are used.
var venues = new List<VenueDto>().AsEnumerable();
HttpClient client = new HttpClient
{
BaseAddress = new Uri("http://localhost:23652/")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.GetAsync("api/Availability?eventType=" + search.EventType + "&beginDate=" + search.StartDate.ToString("MM/dd/yyyy") + "&endDate=" + search.EndDate.ToString("MM/dd/yyyy"));
if (response.IsSuccessStatusCode)
{
venues = await response.Content.ReadAsAsync<IEnumerable<VenueDto>>();
}
else
{
Debug.WriteLine("Index received a bad response from the web service.");
}
return View(venues);
}
return NotFound();
}
public IActionResult CreateWithVenue(string reference)
{
return View(new Event { VenueReference = reference });
}
}
}

View File

@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using ThAmCo.Events.Data;
using ThAmCo.Events.Models;
using System.Net.Http;
using System.Diagnostics;
using ThAmCo.Events.Models.ViewModels.Events;
using ThAmCo.Events.Models.Dto;
namespace ThAmCo.Events.Controllers
{
public class FoodController : Controller
{
EventsDbContext _context;
public FoodController()
{
}
// GET: Food
public async Task<IActionResult> Index()
{
//Get full list of menus and their data from the web service.
HttpClient client = new HttpClient
{
BaseAddress = new Uri("http://localhost:32824")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.GetAsync("api/values");
if (response.IsSuccessStatusCode)
{
var menus = response.Content.ReadAsAsync<IEnumerable<Food>>().Result.ToList();
return View(menus);
}
else
{
Debug.WriteLine("Index received a bad response from the web service.");
}
return NotFound();
}
// GET: Food/Details/5
public async Task<IActionResult> Details(int? id)
{
//Get details of a specific menu from the web service.
if (id == null)
{
return NotFound();
}
HttpClient client = new HttpClient
{
BaseAddress = new Uri("http://localhost:32824")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.GetAsync("api/values/" + id);
if (response.IsSuccessStatusCode)
{
var menu = response.Content.ReadAsAsync<Food>().Result;
return View(menu);
}
else
{
Debug.WriteLine("Index received a bad response from the web service.");
}
return NotFound();
}
// GET: Food/Create
public IActionResult Create()
{
return View();
}
// POST: Food/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Items,Price")] Food food)
{
if (ModelState.IsValid)
{
HttpClient client = new HttpClient()
{
BaseAddress = new Uri("http://localhost:32824/")
};
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
HttpResponseMessage response = await client.PostAsJsonAsync("api/values", food);
return RedirectToAction(nameof(Details), new { id = food.Id });
}
return View(food);
}
// GET: Food/Edit/5
public async Task<IActionResult> Edit(int? id)
{
//TODO: Fix
/*if (id == null)
{
return NotFound();
}
var food = await _context.Food.FindAsync(id);
if (food == null)
{
return NotFound();
}
return View(food);*/
return null;
}
// POST: Food/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Items,Price")] Food food)
{
if (id != food.Id)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(food);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (false)
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(food);
}
}
}

View File

@ -0,0 +1,165 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Controllers
{
public class GuestBookingsController : Controller
{
private readonly EventsDbContext _context;
public GuestBookingsController(EventsDbContext context)
{
_context = context;
}
// GET: GuestBookings
public async Task<IActionResult> Index()
{
var eventsDbContext = _context.Guests.Include(g => g.Customer).Include(g => g.Event);
return View(await eventsDbContext.ToListAsync());
}
// GET: GuestBookings/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
var guestBooking = await _context.Guests
.Include(g => g.Customer)
.Include(g => g.Event)
.FirstOrDefaultAsync(m => m.CustomerId == id);
if (guestBooking == null)
{
return NotFound();
}
return View(guestBooking);
}
// GET: GuestBookings/Create
public IActionResult Create()
{
ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Email");
ViewData["EventId"] = new SelectList(_context.Events, "Id", "Title");
return View();
}
// POST: GuestBookings/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("CustomerId,EventId,Attended")] GuestBooking guestBooking)
{
if (ModelState.IsValid)
{
_context.Add(guestBooking);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Email", guestBooking.CustomerId);
ViewData["EventId"] = new SelectList(_context.Events, "Id", "Title", guestBooking.EventId);
return View(guestBooking);
}
// GET: GuestBookings/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}
var guestBooking = await _context.Guests.FindAsync(id);
if (guestBooking == null)
{
return NotFound();
}
ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Email", guestBooking.CustomerId);
ViewData["EventId"] = new SelectList(_context.Events, "Id", "Title", guestBooking.EventId);
return View(guestBooking);
}
// POST: GuestBookings/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("CustomerId,EventId,Attended")] GuestBooking guestBooking)
{
if (id != guestBooking.CustomerId)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(guestBooking);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!GuestBookingExists(guestBooking.CustomerId))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Email", guestBooking.CustomerId);
ViewData["EventId"] = new SelectList(_context.Events, "Id", "Title", guestBooking.EventId);
return View(guestBooking);
}
// GET: GuestBookings/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}
var guestBooking = await _context.Guests
.Include(g => g.Customer)
.Include(g => g.Event)
.FirstOrDefaultAsync(m => m.CustomerId == id);
if (guestBooking == null)
{
return NotFound();
}
return View(guestBooking);
}
// POST: GuestBookings/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var guestBooking = await _context.Guests.FindAsync(id);
_context.Guests.Remove(guestBooking);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
private bool GuestBookingExists(int id)
{
return _context.Guests.Any(e => e.CustomerId == id);
}
}
}

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ThAmCo.Events.Models;
namespace ThAmCo.Events.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult About()
{
ViewData["Message"] = "Your application description page.";
return View();
}
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@ -0,0 +1,154 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Controllers
{
public class StaffController : Controller
{
private readonly EventsDbContext _context;
public StaffController(EventsDbContext context)
{
_context = context;
}
// GET: Staff
public async Task<IActionResult> Index()
{
return View(await _context.Staff.ToListAsync());
}
// GET: Staff/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
var staff = await _context.Staff.Include(s => s.Staffings).FirstOrDefaultAsync(m => m.Id == id);
//Get staffings for that staff, to show what events they are staffing.
staff.Staffings = await _context.Staffing.Include(m => m.Event).Where(m => m.StaffId == id).ToListAsync();
if (staff == null)
{
return NotFound();
}
return View(staff);
}
// GET: Staff/Create
public IActionResult Create()
{
return View();
}
// POST: Staff/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Surname,FirstName,Email,FirstAid")] Staff staff)
{
if (ModelState.IsValid)
{
_context.Add(staff);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(staff);
}
// GET: Staff/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}
var staff = await _context.Staff.FindAsync(id);
if (staff == null)
{
return NotFound();
}
return View(staff);
}
// POST: Staff/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Surname,FirstName,Email,FirstAid")] Staff staff)
{
if (id != staff.Id)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(staff);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!StaffExists(staff.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(staff);
}
// GET: Staff/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}
var staff = await _context.Staff
.FirstOrDefaultAsync(m => m.Id == id);
if (staff == null)
{
return NotFound();
}
return View(staff);
}
// POST: Staff/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var staff = await _context.Staff.FindAsync(id);
_context.Staff.Remove(staff);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
private bool StaffExists(int id)
{
return _context.Staff.Any(e => e.Id == id);
}
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Data
{
public class Customer
{
public int Id { get; set; }
[Required]
public string Surname { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
public List<GuestBooking> Bookings { get; set; }
public bool IsDeleted { get; set; }
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Data
{
public class Event
{
public int Id { get; set; }
[Required]
public string Title { get; set; }
public DateTime Date { get; set; }
public TimeSpan? Duration { get; set; }
[Required, MaxLength(3), MinLength(3)]
public string TypeId { get; set; }
public List<GuestBooking> Bookings { get; set; }
public string VenueReference { get; set; }
public int FoodReference { get; set; }
public List<Staffing> Staffings { get; set; }
public bool IsDeleted { get; set; }
}
}

View File

@ -0,0 +1,100 @@
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Data
{
public class EventsDbContext : DbContext
{
public DbSet<Customer> Customers { get; set; }
public DbSet<Event> Events { get; set; }
public DbSet<GuestBooking> Guests { get; set; }
public DbSet<Staffing> Staffing { get; set; }
public DbSet<Staff> Staff { get; set; }
private IHostingEnvironment HostEnv { get; }
public EventsDbContext(DbContextOptions<EventsDbContext> 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.events");
builder.Entity<GuestBooking>()
.HasKey(b => new { b.CustomerId, b.EventId });
builder.Entity<Staffing>()
.HasKey(s => new { s.StaffId, s.EventId });
builder.Entity<Customer>()
.HasMany(c => c.Bookings)
.WithOne(b => b.Customer)
.HasForeignKey(b => b.CustomerId);
builder.Entity<Event>()
.HasMany(e => e.Bookings)
.WithOne(b => b.Event)
.HasForeignKey(b => b.EventId);
builder.Entity<Event>()
.HasMany(e => e.Staffings)
.WithOne(b => b.Event)
.HasForeignKey(b => b.EventId);
builder.Entity<Event>()
.Property(e => e.TypeId)
.IsFixedLength();
builder.Entity<Staff>()
.HasMany(s => s.Staffings)
.WithOne(b => b.Staff)
.HasForeignKey(b => b.StaffId);
// seed data for debug / development testing
if (HostEnv != null && HostEnv.IsDevelopment())
{
builder.Entity<Customer>().HasData(
new Customer { Id = 1, Surname = "Robertson", FirstName = "Robert", Email = "bob@example.com" },
new Customer { Id = 2, Surname = "Thornton", FirstName = "Betty", Email = "betty@example.com" },
new Customer { Id = 3, Surname = "Jellybeans", FirstName = "Jin", Email = "jin@example.com" }
);
builder.Entity<Event>().HasData(
new Event { Id = 1, Title = "Bob's Big 50", Date = new DateTime(2016, 4, 12), Duration = new TimeSpan(6, 0, 0), TypeId = "PTY" },
new Event { Id = 2, Title = "Best Wedding Yet", Date = new DateTime(2018, 12, 1), Duration = new TimeSpan(12, 0, 0), TypeId = "WED" }
);
builder.Entity<GuestBooking>().HasData(
new GuestBooking { CustomerId = 1, EventId = 1, Attended = true },
new GuestBooking { CustomerId = 2, EventId = 1, Attended = false },
new GuestBooking { CustomerId = 1, EventId = 2, Attended = false },
new GuestBooking { CustomerId = 3, EventId = 2, Attended = false }
);
builder.Entity<Staff>().HasData(
new Staff { Id = 1, Surname = "Partridge", FirstName = "Alan", Email = "a@a.a", FirstAid = false },
new Staff { Id = 2, Surname = "Stephenson", FirstName = "Roger", Email = "rege@hotmail.com", FirstAid = true},
new Staff { Id = 3, Surname = "Smith", FirstName = "Alans", Email = "alans@jims.net", FirstAid = false }
);
builder.Entity<Staffing>().HasData(
new Staffing { StaffId = 1, EventId = 2 },
new Staffing { StaffId = 2, EventId = 1 },
new Staffing { StaffId = 3, EventId = 1 }
);
}
}
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Events.Data
{
public class Food
{
public int Id { get; set; }
public string Items { get; set; }
public double Price { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Data
{
public class GuestBooking
{
public int CustomerId { get; set; }
public Customer Customer { get; set; }
public int EventId { get; set; }
public Event Event { get; set; }
public bool Attended { get; set; }
}
}

View File

@ -0,0 +1,116 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Data.Migrations
{
[DbContext(typeof(EventsDbContext))]
[Migration("20181029103724_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("thamco.events")
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("ThAmCo.Events.Data.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<string>("FirstName")
.IsRequired();
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Customers");
b.HasData(
new { Id = 1, Email = "bob@example.com", FirstName = "Robert", Surname = "Robertson" },
new { Id = 2, Email = "betty@example.com", FirstName = "Betty", Surname = "Thornton" },
new { Id = 3, Email = "jin@example.com", FirstName = "Jin", Surname = "Jellybeans" }
);
});
modelBuilder.Entity("ThAmCo.Events.Data.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Date");
b.Property<TimeSpan?>("Duration");
b.Property<string>("Title")
.IsRequired();
b.Property<string>("TypeId")
.IsRequired()
.IsFixedLength(true)
.HasMaxLength(3);
b.HasKey("Id");
b.ToTable("Events");
b.HasData(
new { Id = 1, Date = new DateTime(2016, 4, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), Duration = new TimeSpan(0, 6, 0, 0, 0), Title = "Bob's Big 50", TypeId = "PTY" },
new { Id = 2, Date = new DateTime(2018, 12, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Duration = new TimeSpan(0, 12, 0, 0, 0), Title = "Best Wedding Yet", TypeId = "WED" }
);
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.Property<int>("CustomerId");
b.Property<int>("EventId");
b.Property<bool>("Attended");
b.HasKey("CustomerId", "EventId");
b.HasIndex("EventId");
b.ToTable("Guests");
b.HasData(
new { CustomerId = 1, EventId = 1, Attended = true },
new { CustomerId = 2, EventId = 1, Attended = false },
new { CustomerId = 1, EventId = 2, Attended = false },
new { CustomerId = 3, EventId = 2, Attended = false }
);
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.HasOne("ThAmCo.Events.Data.Customer", "Customer")
.WithMany("Bookings")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Bookings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,130 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ThAmCo.Events.Data.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "thamco.events");
migrationBuilder.CreateTable(
name: "Customers",
schema: "thamco.events",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Surname = table.Column<string>(nullable: false),
FirstName = table.Column<string>(nullable: false),
Email = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Events",
schema: "thamco.events",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(nullable: false),
Date = table.Column<DateTime>(nullable: false),
Duration = table.Column<TimeSpan>(nullable: true),
TypeId = table.Column<string>(fixedLength: true, maxLength: 3, nullable: false),
},
constraints: table =>
{
table.PrimaryKey("PK_Events", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Guests",
schema: "thamco.events",
columns: table => new
{
CustomerId = table.Column<int>(nullable: false),
EventId = table.Column<int>(nullable: false),
Attended = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Guests", x => new { x.CustomerId, x.EventId });
table.ForeignKey(
name: "FK_Guests_Customers_CustomerId",
column: x => x.CustomerId,
principalSchema: "thamco.events",
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Guests_Events_EventId",
column: x => x.EventId,
principalSchema: "thamco.events",
principalTable: "Events",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
schema: "thamco.events",
table: "Customers",
columns: new[] { "Id", "Email", "FirstName", "Surname" },
values: new object[,]
{
{ 1, "bob@example.com", "Robert", "Robertson" },
{ 2, "betty@example.com", "Betty", "Thornton" },
{ 3, "jin@example.com", "Jin", "Jellybeans" }
});
migrationBuilder.InsertData(
schema: "thamco.events",
table: "Events",
columns: new[] { "Id", "Date", "Duration", "Title", "TypeId" },
values: new object[,]
{
{ 1, new DateTime(2016, 4, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 6, 0, 0, 0), "Bob's Big 50", "PTY" },
{ 2, new DateTime(2018, 12, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 12, 0, 0, 0), "Best Wedding Yet", "WED" }
});
migrationBuilder.InsertData(
schema: "thamco.events",
table: "Guests",
columns: new[] { "CustomerId", "EventId", "Attended" },
values: new object[,]
{
{ 1, 1, true },
{ 2, 1, false },
{ 1, 2, false },
{ 3, 2, false }
});
migrationBuilder.CreateIndex(
name: "IX_Guests_EventId",
schema: "thamco.events",
table: "Guests",
column: "EventId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Guests",
schema: "thamco.events");
migrationBuilder.DropTable(
name: "Customers",
schema: "thamco.events");
migrationBuilder.DropTable(
name: "Events",
schema: "thamco.events");
}
}
}

View File

@ -0,0 +1,178 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Data.Migrations
{
[DbContext(typeof(EventsDbContext))]
[Migration("20181127120440_AddStaffing")]
partial class AddStaffing
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("thamco.events")
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("ThAmCo.Events.Data.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<string>("FirstName")
.IsRequired();
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Customers");
b.HasData(
new { Id = 1, Email = "bob@example.com", FirstName = "Robert", Surname = "Robertson" },
new { Id = 2, Email = "betty@example.com", FirstName = "Betty", Surname = "Thornton" },
new { Id = 3, Email = "jin@example.com", FirstName = "Jin", Surname = "Jellybeans" }
);
});
modelBuilder.Entity("ThAmCo.Events.Data.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Date");
b.Property<TimeSpan?>("Duration");
b.Property<string>("Title")
.IsRequired();
b.Property<string>("TypeId")
.IsRequired()
.IsFixedLength(true)
.HasMaxLength(3);
b.Property<string>("VenueReference");
b.HasKey("Id");
b.ToTable("Events");
b.HasData(
new { Id = 1, Date = new DateTime(2016, 4, 12, 0, 0, 0, 0, DateTimeKind.Unspecified), Duration = new TimeSpan(0, 6, 0, 0, 0), Title = "Bob's Big 50", TypeId = "PTY" },
new { Id = 2, Date = new DateTime(2018, 12, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), Duration = new TimeSpan(0, 12, 0, 0, 0), Title = "Best Wedding Yet", TypeId = "WED" }
);
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.Property<int>("CustomerId");
b.Property<int>("EventId");
b.Property<bool>("Attended");
b.HasKey("CustomerId", "EventId");
b.HasIndex("EventId");
b.ToTable("Guests");
b.HasData(
new { CustomerId = 1, EventId = 1, Attended = true },
new { CustomerId = 2, EventId = 1, Attended = false },
new { CustomerId = 1, EventId = 2, Attended = false },
new { CustomerId = 3, EventId = 2, Attended = false }
);
});
modelBuilder.Entity("ThAmCo.Events.Data.Staff", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<bool>("FirstAid");
b.Property<string>("FirstName")
.IsRequired();
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Staff");
b.HasData(
new { Id = 1, Email = "a@a.a", FirstAid = false, FirstName = "Alan", Surname = "Partridge" },
new { Id = 2, Email = "rege@hotmail.com", FirstAid = true, FirstName = "Roger", Surname = "Stephenson" },
new { Id = 3, Email = "alans@jims.net", FirstAid = false, FirstName = "Alans", Surname = "Smith" }
);
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.Property<int>("StaffId");
b.Property<int>("EventId");
b.HasKey("StaffId", "EventId");
b.HasIndex("EventId");
b.ToTable("Staffing");
b.HasData(
new { StaffId = 1, EventId = 2 },
new { StaffId = 2, EventId = 1 },
new { StaffId = 3, EventId = 1 }
);
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.HasOne("ThAmCo.Events.Data.Customer", "Customer")
.WithMany("Bookings")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Bookings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Staffings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Staff", "Staff")
.WithMany("Staffings")
.HasForeignKey("StaffId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,119 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ThAmCo.Events.Data.Migrations
{
public partial class AddStaffing : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "VenueReference",
schema: "thamco.events",
table: "Events",
nullable: true);
migrationBuilder.CreateTable(
name: "Staff",
schema: "thamco.events",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Surname = table.Column<string>(nullable: false),
FirstName = table.Column<string>(nullable: false),
Email = table.Column<string>(nullable: false),
FirstAid = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Staff", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Staffing",
schema: "thamco.events",
columns: table => new
{
StaffId = table.Column<int>(nullable: false),
EventId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Staffing", x => new { x.StaffId, x.EventId });
table.ForeignKey(
name: "FK_Staffing_Events_EventId",
column: x => x.EventId,
principalSchema: "thamco.events",
principalTable: "Events",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Staffing_Staff_StaffId",
column: x => x.StaffId,
principalSchema: "thamco.events",
principalTable: "Staff",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
schema: "thamco.events",
table: "Staff",
columns: new[] { "Id", "Email", "FirstAid", "FirstName", "Surname" },
values: new object[] { 1, "a@a.a", false, "Alan", "Partridge" });
migrationBuilder.InsertData(
schema: "thamco.events",
table: "Staff",
columns: new[] { "Id", "Email", "FirstAid", "FirstName", "Surname" },
values: new object[] { 2, "rege@hotmail.com", true, "Roger", "Stephenson" });
migrationBuilder.InsertData(
schema: "thamco.events",
table: "Staff",
columns: new[] { "Id", "Email", "FirstAid", "FirstName", "Surname" },
values: new object[] { 3, "alans@jims.net", false, "Alans", "Smith" });
migrationBuilder.InsertData(
schema: "thamco.events",
table: "Staffing",
columns: new[] { "StaffId", "EventId" },
values: new object[] { 1, 2 });
migrationBuilder.InsertData(
schema: "thamco.events",
table: "Staffing",
columns: new[] { "StaffId", "EventId" },
values: new object[] { 2, 1 });
migrationBuilder.InsertData(
schema: "thamco.events",
table: "Staffing",
columns: new[] { "StaffId", "EventId" },
values: new object[] { 3, 1 });
migrationBuilder.CreateIndex(
name: "IX_Staffing_EventId",
schema: "thamco.events",
table: "Staffing",
column: "EventId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Staffing",
schema: "thamco.events");
migrationBuilder.DropTable(
name: "Staff",
schema: "thamco.events");
migrationBuilder.DropColumn(
name: "VenueReference",
schema: "thamco.events",
table: "Events");
}
}
}

View File

@ -0,0 +1,262 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Data.Migrations
{
[DbContext(typeof(EventsDbContext))]
[Migration("20181204160544_AddFoodReference")]
partial class AddFoodReference
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("thamco.events")
.HasAnnotation("ProductVersion", "2.2.0-preview3-35497")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("ThAmCo.Events.Data.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<string>("FirstName")
.IsRequired();
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Customers");
b.HasData(
new
{
Id = 1,
Email = "bob@example.com",
FirstName = "Robert",
Surname = "Robertson"
},
new
{
Id = 2,
Email = "betty@example.com",
FirstName = "Betty",
Surname = "Thornton"
},
new
{
Id = 3,
Email = "jin@example.com",
FirstName = "Jin",
Surname = "Jellybeans"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Date");
b.Property<TimeSpan?>("Duration");
b.Property<int>("FoodReference");
b.Property<string>("Title")
.IsRequired();
b.Property<string>("TypeId")
.IsRequired()
.IsFixedLength(true)
.HasMaxLength(3);
b.Property<string>("VenueReference");
b.HasKey("Id");
b.ToTable("Events");
b.HasData(
new
{
Id = 1,
Date = new DateTime(2016, 4, 12, 0, 0, 0, 0, DateTimeKind.Unspecified),
Duration = new TimeSpan(0, 6, 0, 0, 0),
FoodReference = 0,
Title = "Bob's Big 50",
TypeId = "PTY"
},
new
{
Id = 2,
Date = new DateTime(2018, 12, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Duration = new TimeSpan(0, 12, 0, 0, 0),
FoodReference = 0,
Title = "Best Wedding Yet",
TypeId = "WED"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.Property<int>("CustomerId");
b.Property<int>("EventId");
b.Property<bool>("Attended");
b.HasKey("CustomerId", "EventId");
b.HasIndex("EventId");
b.ToTable("Guests");
b.HasData(
new
{
CustomerId = 1,
EventId = 1,
Attended = true
},
new
{
CustomerId = 2,
EventId = 1,
Attended = false
},
new
{
CustomerId = 1,
EventId = 2,
Attended = false
},
new
{
CustomerId = 3,
EventId = 2,
Attended = false
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Staff", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<bool>("FirstAid");
b.Property<string>("FirstName")
.IsRequired();
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Staff");
b.HasData(
new
{
Id = 1,
Email = "a@a.a",
FirstAid = false,
FirstName = "Alan",
Surname = "Partridge"
},
new
{
Id = 2,
Email = "rege@hotmail.com",
FirstAid = true,
FirstName = "Roger",
Surname = "Stephenson"
},
new
{
Id = 3,
Email = "alans@jims.net",
FirstAid = false,
FirstName = "Alans",
Surname = "Smith"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.Property<int>("StaffId");
b.Property<int>("EventId");
b.HasKey("StaffId", "EventId");
b.HasIndex("EventId");
b.ToTable("Staffing");
b.HasData(
new
{
StaffId = 1,
EventId = 2
},
new
{
StaffId = 2,
EventId = 1
},
new
{
StaffId = 3,
EventId = 1
});
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.HasOne("ThAmCo.Events.Data.Customer", "Customer")
.WithMany("Bookings")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Bookings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Staffings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Staff", "Staff")
.WithMany("Staffings")
.HasForeignKey("StaffId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace ThAmCo.Events.Data.Migrations
{
public partial class AddFoodReference : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "FoodReference",
schema: "thamco.events",
table: "Events",
nullable: false,
defaultValue: 0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "FoodReference",
schema: "thamco.events",
table: "Events");
}
}
}

View File

@ -0,0 +1,266 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Data.Migrations
{
[DbContext(typeof(EventsDbContext))]
[Migration("20181205115027_AddSoftDeleteEvent")]
partial class AddSoftDeleteEvent
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("thamco.events")
.HasAnnotation("ProductVersion", "2.2.0-preview3-35497")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("ThAmCo.Events.Data.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<string>("FirstName")
.IsRequired();
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Customers");
b.HasData(
new
{
Id = 1,
Email = "bob@example.com",
FirstName = "Robert",
Surname = "Robertson"
},
new
{
Id = 2,
Email = "betty@example.com",
FirstName = "Betty",
Surname = "Thornton"
},
new
{
Id = 3,
Email = "jin@example.com",
FirstName = "Jin",
Surname = "Jellybeans"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Date");
b.Property<TimeSpan?>("Duration");
b.Property<int>("FoodReference");
b.Property<bool>("IsDeleted");
b.Property<string>("Title")
.IsRequired();
b.Property<string>("TypeId")
.IsRequired()
.IsFixedLength(true)
.HasMaxLength(3);
b.Property<string>("VenueReference");
b.HasKey("Id");
b.ToTable("Events");
b.HasData(
new
{
Id = 1,
Date = new DateTime(2016, 4, 12, 0, 0, 0, 0, DateTimeKind.Unspecified),
Duration = new TimeSpan(0, 6, 0, 0, 0),
FoodReference = 0,
IsDeleted = false,
Title = "Bob's Big 50",
TypeId = "PTY"
},
new
{
Id = 2,
Date = new DateTime(2018, 12, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Duration = new TimeSpan(0, 12, 0, 0, 0),
FoodReference = 0,
IsDeleted = false,
Title = "Best Wedding Yet",
TypeId = "WED"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.Property<int>("CustomerId");
b.Property<int>("EventId");
b.Property<bool>("Attended");
b.HasKey("CustomerId", "EventId");
b.HasIndex("EventId");
b.ToTable("Guests");
b.HasData(
new
{
CustomerId = 1,
EventId = 1,
Attended = true
},
new
{
CustomerId = 2,
EventId = 1,
Attended = false
},
new
{
CustomerId = 1,
EventId = 2,
Attended = false
},
new
{
CustomerId = 3,
EventId = 2,
Attended = false
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Staff", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<bool>("FirstAid");
b.Property<string>("FirstName")
.IsRequired();
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Staff");
b.HasData(
new
{
Id = 1,
Email = "a@a.a",
FirstAid = false,
FirstName = "Alan",
Surname = "Partridge"
},
new
{
Id = 2,
Email = "rege@hotmail.com",
FirstAid = true,
FirstName = "Roger",
Surname = "Stephenson"
},
new
{
Id = 3,
Email = "alans@jims.net",
FirstAid = false,
FirstName = "Alans",
Surname = "Smith"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.Property<int>("StaffId");
b.Property<int>("EventId");
b.HasKey("StaffId", "EventId");
b.HasIndex("EventId");
b.ToTable("Staffing");
b.HasData(
new
{
StaffId = 1,
EventId = 2
},
new
{
StaffId = 2,
EventId = 1
},
new
{
StaffId = 3,
EventId = 1
});
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.HasOne("ThAmCo.Events.Data.Customer", "Customer")
.WithMany("Bookings")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Bookings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Staffings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Staff", "Staff")
.WithMany("Staffings")
.HasForeignKey("StaffId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace ThAmCo.Events.Data.Migrations
{
public partial class AddSoftDeleteEvent : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
schema: "thamco.events",
table: "Events",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsDeleted",
schema: "thamco.events",
table: "Events");
}
}
}

View File

@ -0,0 +1,271 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Data.Migrations
{
[DbContext(typeof(EventsDbContext))]
[Migration("20181205125146_AddSoftDeleteCustomer")]
partial class AddSoftDeleteCustomer
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("thamco.events")
.HasAnnotation("ProductVersion", "2.2.0-preview3-35497")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("ThAmCo.Events.Data.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<string>("FirstName")
.IsRequired();
b.Property<bool>("IsDeleted");
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Customers");
b.HasData(
new
{
Id = 1,
Email = "bob@example.com",
FirstName = "Robert",
IsDeleted = false,
Surname = "Robertson"
},
new
{
Id = 2,
Email = "betty@example.com",
FirstName = "Betty",
IsDeleted = false,
Surname = "Thornton"
},
new
{
Id = 3,
Email = "jin@example.com",
FirstName = "Jin",
IsDeleted = false,
Surname = "Jellybeans"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Date");
b.Property<TimeSpan?>("Duration");
b.Property<int>("FoodReference");
b.Property<bool>("IsDeleted");
b.Property<string>("Title")
.IsRequired();
b.Property<string>("TypeId")
.IsRequired()
.IsFixedLength(true)
.HasMaxLength(3);
b.Property<string>("VenueReference");
b.HasKey("Id");
b.ToTable("Events");
b.HasData(
new
{
Id = 1,
Date = new DateTime(2016, 4, 12, 0, 0, 0, 0, DateTimeKind.Unspecified),
Duration = new TimeSpan(0, 6, 0, 0, 0),
FoodReference = 0,
IsDeleted = false,
Title = "Bob's Big 50",
TypeId = "PTY"
},
new
{
Id = 2,
Date = new DateTime(2018, 12, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Duration = new TimeSpan(0, 12, 0, 0, 0),
FoodReference = 0,
IsDeleted = false,
Title = "Best Wedding Yet",
TypeId = "WED"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.Property<int>("CustomerId");
b.Property<int>("EventId");
b.Property<bool>("Attended");
b.HasKey("CustomerId", "EventId");
b.HasIndex("EventId");
b.ToTable("Guests");
b.HasData(
new
{
CustomerId = 1,
EventId = 1,
Attended = true
},
new
{
CustomerId = 2,
EventId = 1,
Attended = false
},
new
{
CustomerId = 1,
EventId = 2,
Attended = false
},
new
{
CustomerId = 3,
EventId = 2,
Attended = false
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Staff", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<bool>("FirstAid");
b.Property<string>("FirstName")
.IsRequired();
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Staff");
b.HasData(
new
{
Id = 1,
Email = "a@a.a",
FirstAid = false,
FirstName = "Alan",
Surname = "Partridge"
},
new
{
Id = 2,
Email = "rege@hotmail.com",
FirstAid = true,
FirstName = "Roger",
Surname = "Stephenson"
},
new
{
Id = 3,
Email = "alans@jims.net",
FirstAid = false,
FirstName = "Alans",
Surname = "Smith"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.Property<int>("StaffId");
b.Property<int>("EventId");
b.HasKey("StaffId", "EventId");
b.HasIndex("EventId");
b.ToTable("Staffing");
b.HasData(
new
{
StaffId = 1,
EventId = 2
},
new
{
StaffId = 2,
EventId = 1
},
new
{
StaffId = 3,
EventId = 1
});
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.HasOne("ThAmCo.Events.Data.Customer", "Customer")
.WithMany("Bookings")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Bookings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Staffings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Staff", "Staff")
.WithMany("Staffings")
.HasForeignKey("StaffId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace ThAmCo.Events.Data.Migrations
{
public partial class AddSoftDeleteCustomer : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
schema: "thamco.events",
table: "Customers",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsDeleted",
schema: "thamco.events",
table: "Customers");
}
}
}

View File

@ -0,0 +1,269 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Data.Migrations
{
[DbContext(typeof(EventsDbContext))]
partial class EventsDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("thamco.events")
.HasAnnotation("ProductVersion", "2.2.0-preview3-35497")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("ThAmCo.Events.Data.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<string>("FirstName")
.IsRequired();
b.Property<bool>("IsDeleted");
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Customers");
b.HasData(
new
{
Id = 1,
Email = "bob@example.com",
FirstName = "Robert",
IsDeleted = false,
Surname = "Robertson"
},
new
{
Id = 2,
Email = "betty@example.com",
FirstName = "Betty",
IsDeleted = false,
Surname = "Thornton"
},
new
{
Id = 3,
Email = "jin@example.com",
FirstName = "Jin",
IsDeleted = false,
Surname = "Jellybeans"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Event", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("Date");
b.Property<TimeSpan?>("Duration");
b.Property<int>("FoodReference");
b.Property<bool>("IsDeleted");
b.Property<string>("Title")
.IsRequired();
b.Property<string>("TypeId")
.IsRequired()
.IsFixedLength(true)
.HasMaxLength(3);
b.Property<string>("VenueReference");
b.HasKey("Id");
b.ToTable("Events");
b.HasData(
new
{
Id = 1,
Date = new DateTime(2016, 4, 12, 0, 0, 0, 0, DateTimeKind.Unspecified),
Duration = new TimeSpan(0, 6, 0, 0, 0),
FoodReference = 0,
IsDeleted = false,
Title = "Bob's Big 50",
TypeId = "PTY"
},
new
{
Id = 2,
Date = new DateTime(2018, 12, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
Duration = new TimeSpan(0, 12, 0, 0, 0),
FoodReference = 0,
IsDeleted = false,
Title = "Best Wedding Yet",
TypeId = "WED"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.Property<int>("CustomerId");
b.Property<int>("EventId");
b.Property<bool>("Attended");
b.HasKey("CustomerId", "EventId");
b.HasIndex("EventId");
b.ToTable("Guests");
b.HasData(
new
{
CustomerId = 1,
EventId = 1,
Attended = true
},
new
{
CustomerId = 2,
EventId = 1,
Attended = false
},
new
{
CustomerId = 1,
EventId = 2,
Attended = false
},
new
{
CustomerId = 3,
EventId = 2,
Attended = false
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Staff", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.IsRequired();
b.Property<bool>("FirstAid");
b.Property<string>("FirstName")
.IsRequired();
b.Property<string>("Surname")
.IsRequired();
b.HasKey("Id");
b.ToTable("Staff");
b.HasData(
new
{
Id = 1,
Email = "a@a.a",
FirstAid = false,
FirstName = "Alan",
Surname = "Partridge"
},
new
{
Id = 2,
Email = "rege@hotmail.com",
FirstAid = true,
FirstName = "Roger",
Surname = "Stephenson"
},
new
{
Id = 3,
Email = "alans@jims.net",
FirstAid = false,
FirstName = "Alans",
Surname = "Smith"
});
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.Property<int>("StaffId");
b.Property<int>("EventId");
b.HasKey("StaffId", "EventId");
b.HasIndex("EventId");
b.ToTable("Staffing");
b.HasData(
new
{
StaffId = 1,
EventId = 2
},
new
{
StaffId = 2,
EventId = 1
},
new
{
StaffId = 3,
EventId = 1
});
});
modelBuilder.Entity("ThAmCo.Events.Data.GuestBooking", b =>
{
b.HasOne("ThAmCo.Events.Data.Customer", "Customer")
.WithMany("Bookings")
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Bookings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("ThAmCo.Events.Data.Staffing", b =>
{
b.HasOne("ThAmCo.Events.Data.Event", "Event")
.WithMany("Staffings")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("ThAmCo.Events.Data.Staff", "Staff")
.WithMany("Staffings")
.HasForeignKey("StaffId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Events.Data
{
public class Staff
{
public int Id { get; set; }
[Required]
public string Surname { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
public List<Staffing> Staffings { get; set; }
public bool FirstAid { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Data
{
public class Staffing
{
public int StaffId { get; set; }
public Staff Staff { get; set; }
public int EventId { get; set; }
public Event Event { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Models
{
public class EventTypeDto
{
[Required, MaxLength(3), MinLength(3)]
public string TypeId { get; set; }
public string Title { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Events.Models.Dto
{
public class MenuDTO
{
public int Id { get; set; }
public string Items { get; set; }
public double Price { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Models
{
public class ReservationCreateDto
{
[Required, DataType(DataType.Date)]
public DateTime EventDate { get; set; }
[Required, MinLength(5), MaxLength(5)]
public string VenueCode { get; set; }
[Required]
public string StaffId { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Events.Models
{
public class ReservationDto
{
public string Reference { get; set; }
public DateTime EventDate { get; set; }
public string VenueCode { get; set; }
public DateTime whenMade { get; set; }
public string StaffId { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Events.Models
{
public class VenueDto
{
public string Code { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int Capacity { get; set; }
public DateTime Date { get; set; }
public double CostPerHour { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace ThAmCo.Events.Models
{
public class ErrorViewModel
{
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Models
{
public class CustomerCreateModel
{
public int Id { get; set; }
[Required]
public string Surname { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
public List<Event> Events { get; set; }
public int InitialEvent { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class EventAddCustomerModel
{
public int EventId { get; set; }
public List<Customer> Customer { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ThAmCo.Events.Models.Dto;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class EventAddMenuModel
{
public int EventId { get; set; }
public List<MenuDTO> Menus { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class EventAddStaffModel
{
public int EventId { get; set; }
public List<Staff> Staff { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Models
{
public class EventCreateModel
{
[Required]
public string Title { get; set; }
[Required]
public DateTime Date { get; set; }
public TimeSpan? Duration { get; set; }
[Required, MaxLength(3), MinLength(3)]
public string TypeId { get; set; }
public int VenueID { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Models
{
public class EventCreateReservationModel
{
public int Id { get; set; }
public DateTime VenueDate { get; set; }
public string VenueCode { get; set; }
}
}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class EventCreateWithVenueModel
{
public int EventId { get; set; }
[Required]
public string EventTitle { get; set; }
public DateTime EventDate { get; set; }
public TimeSpan? EventDuration { get; set; }
[Required, MaxLength(3), MinLength(3)]
public string EventTypeId { get; set; }
public string VenueCode { get; set; }
public string VenueName { get; set; }
public string VenueDescription { get; set; }
public int VenueCapacity { get; set; }
public DateTime VenueDate { get; set; }
public double VenueCostPerHour { get; set; }
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Models
{
public class EventDetailsModel
{
public int Id { get; set; }
[Required]
public string Title { get; set; }
public DateTime Date { get; set; }
public TimeSpan? Duration { get; set; }
[Required, MaxLength(3), MinLength(3)]
public string TypeId { get; set; }
public List<GuestBooking> Bookings { get; set; }
public ReservationDto Reservation { get; set; }
public string Reference { get; set; }
public int FoodReference { get; set; }
public List<Staffing> Staffing { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class EventEditModel
{
public int Id { get; set; }
[Required]
public string Title { get; set; }
public TimeSpan? Duration { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class EventFindMenuModel
{
public string EventType { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class EventFindVenueModel
{
[Required, MaxLength(3), MinLength(3)]
public string EventType { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using ThAmCo.Events.Data;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class EventIndexModel
{
public int Id { get; set; }
[Required]
public string Title { get; set; }
public DateTime Date { get; set; }
public TimeSpan? Duration { get; set; }
[Required, MaxLength(3), MinLength(3)]
public string TypeId { get; set; }
public List<GuestBooking> Bookings { get; set; }
public string VenueReference { get; set; }
public List<Staffing> Staffings { get; set; }
public bool FirstAid { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class EventRegisterAttendanceModel
{
public int EventId { get; set; }
public int CustomerId { get; set; }
public bool Attending { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace ThAmCo.Events.Models.ViewModels.Events
{
public class SelectVenueGetModel
{
public int? Id { get; set; }
[Required, MaxLength(3), MinLength(3)]
public string EventType { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace ThAmCo.Events.Models
{
public class SelectVenueModel
{
public int Id { get; set; }
public List<VenueDto> Venues { get; set; }
}
}

38
ThAmCo.Events/Program.cs Normal file
View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using ThAmCo.Events.Data;
namespace ThAmCo.Events
{
public class Program
{
public static void Main(string[] args)
{
var host = CreateWebHostBuilder(args).Build();
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
var env = services.GetRequiredService<IHostingEnvironment>();
if (env.IsDevelopment())
{
var context = services.GetRequiredService<EventsDbContext>();
context.Database.EnsureDeleted();
context.Database.Migrate();
}
}
host.Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}

View File

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:22263",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ThAmCo.Events": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

65
ThAmCo.Events/Startup.cs Normal file
View File

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ThAmCo.Events.Data;
namespace ThAmCo.Events
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddDbContext<EventsDbContext>(options =>
{
var cs = Configuration.GetConnectionString("EventsSqlConnection");
options.UseSqlServer(cs);
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Models\ViewModels\Events\EventFindMenuModel.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,48 @@
@model ThAmCo.Events.Models.CustomerCreateModel
@{
ViewData["Title"] = "Create";
}
<h2>Create</h2>
<h4>Customer</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Surname" class="control-label"></label>
<input asp-for="Surname" class="form-control" />
<span asp-validation-for="Surname" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="FirstName" class="control-label"></label>
<input asp-for="FirstName" class="form-control" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Email" class="control-label"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="InitialEvent" class="control-label"></label>
<select asp-for="InitialEvent" class="form-control" asp-items="ViewBag.EventLists"></select>
<span asp-validation-for="InitialEvent" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,44 @@
@model ThAmCo.Events.Data.Customer
@{
ViewData["Title"] = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Customer</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Surname)
</dt>
<dd>
@Html.DisplayFor(model => model.Surname)
</dd>
<dt>
@Html.DisplayNameFor(model => model.FirstName)
</dt>
<dd>
@Html.DisplayFor(model => model.FirstName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Email)
</dt>
<dd>
@Html.DisplayFor(model => model.Email)
</dd>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="Id" />
<input type="submit" value="Delete" class="btn btn-default" />
</form>
<form asp-action="AnonDelete">
<input type="hidden" asp-for="Id" />
<input type="submit" value="Delete Anonymously" class="btn btn-default" /> |
<a asp-action="Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,80 @@
@model ThAmCo.Events.Data.Customer
@{
ViewData["Title"] = "Details";
}
<h2>Details</h2>
<div>
<h4>Customer</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Surname)
</dt>
<dd>
@Html.DisplayFor(model => model.Surname)
</dd>
<dt>
@Html.DisplayNameFor(model => model.FirstName)
</dt>
<dd>
@Html.DisplayFor(model => model.FirstName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Email)
</dt>
<dd>
@Html.DisplayFor(model => model.Email)
</dd>
</dl>
</div>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Bookings.FirstOrDefault().Event.Title)
</th>
<th>
@Html.DisplayNameFor(model => model.Bookings.FirstOrDefault().Event.Date)
</th>
<th>
@Html.DisplayNameFor(model => model.Bookings.FirstOrDefault().Event.Duration)
</th>
<th>
@Html.DisplayNameFor(model => model.Bookings.FirstOrDefault().Event.TypeId)
</th>
<th>
@Html.DisplayNameFor(model => model.Bookings.FirstOrDefault().Attended)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Bookings)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Event.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Event.Date)
</td>
<td>
@Html.DisplayFor(modelItem => item.Event.Duration)
</td>
<td>
@Html.DisplayFor(modelItem => item.Event.TypeId)
</td>
<td>
@Html.DisplayFor(modelItem => item.Attended)
</td>
</tr>
}
</tbody>
</table>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |
<a asp-action="Index">Back to List</a>
</div>

View File

@ -0,0 +1,44 @@
@model ThAmCo.Events.Data.Customer
@{
ViewData["Title"] = "Edit";
}
<h2>Edit</h2>
<h4>Customer</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="Surname" class="control-label"></label>
<input asp-for="Surname" class="form-control" />
<span asp-validation-for="Surname" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="FirstName" class="control-label"></label>
<input asp-for="FirstName" class="form-control" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Email" class="control-label"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,47 @@
@model IEnumerable<ThAmCo.Events.Data.Customer>
@{
ViewData["Title"] = "Index";
}
<h2>Index</h2>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Surname)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.Email)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Surname)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,49 @@
@model ThAmCo.Events.Models.ViewModels.Events.EventAddCustomerModel
@{
ViewData["Title"] = "AddCustomer";
}
<h2>AddCustomer</h2>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Customer.FirstOrDefault().Surname)
</th>
<th>
@Html.DisplayNameFor(model => model.Customer.FirstOrDefault().FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.Customer.FirstOrDefault().Email)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Customer)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Surname)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
<form asp-action="AddCustomer">
<input type="hidden" asp-for="EventId" />
@Html.Hidden("EventID", Model.EventId)
@Html.Hidden("CustomerID", item.Id)
<input type="submit" value="Select" />
</form>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,48 @@
@model ThAmCo.Events.Models.ViewModels.Events.EventAddMenuModel
@{
ViewData["Title"] = "AddMenu";
}
<h2>AddMenu</h2>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Menus.FirstOrDefault().Id)
</th>
<th>
@Html.DisplayNameFor(model => model.Menus.FirstOrDefault().Items)
</th>
<th>
@Html.DisplayNameFor(model => model.Menus.FirstOrDefault().Price)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Menus)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Items)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
</td>
<td>
<form asp-action="AddMenu">
<input type="hidden" asp-for="EventId" />
@Html.Hidden("EventID", Model.EventId)
@Html.Hidden("MenuID", item.Id)
<input type="submit" value="Select" />
</form>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,55 @@
@model ThAmCo.Events.Models.ViewModels.Events.EventAddStaffModel
@{
ViewData["Title"] = "AddStaff";
}
<h2>AddStaff</h2>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Staff.FirstOrDefault().Surname)
</th>
<th>
@Html.DisplayNameFor(model => model.Staff.FirstOrDefault().FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.Staff.FirstOrDefault().Email)
</th>
<th>
@Html.DisplayNameFor(model => model.Staff.FirstOrDefault().FirstAid)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Staff)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Surname)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstAid)
</td>
<td>
<form asp-action="AddStaff">
<input type="hidden" asp-for="EventId" />
@Html.Hidden("EventID", Model.EventId)
@Html.Hidden("StaffID", item.Id)
<input type="submit" value="Select" />
</form>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,48 @@
@model ThAmCo.Events.Models.EventCreateModel
@{
ViewData["Title"] = "Create";
}
<h2>Create</h2>
<h4>Event</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Title" class="control-label"></label>
<input asp-for="Title" class="form-control" />
<span asp-validation-for="Title" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Date" class="control-label"></label>
<input type="date" asp-for="Date" class="form-control" />
<span asp-validation-for="Date" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Duration" class="control-label"></label>
<input type="time" asp-for="Duration" class="form-control" />
<span asp-validation-for="Duration" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="TypeId" class="control-label"></label>
<input asp-for="TypeId" class="form-control"></input>
<span asp-validation-for="TypeId" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Continue" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,46 @@
@model ThAmCo.Events.Data.Event
@{
ViewData["Title"] = "CreateWithVenue";
}
<h2>CreateWithVenue</h2>
<h4>Event</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Title" class="control-label"></label>
<input asp-for="Title" class="form-control" />
<span asp-validation-for="Title" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Date" class="control-label"></label>
<input asp-for="Date" class="form-control" />
<span asp-validation-for="Date" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Duration" class="control-label"></label>
<input asp-for="Duration" class="form-control" />
<span asp-validation-for="Duration" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="TypeId" class="control-label"></label>
<input asp-for="TypeId" class="form-control" />
<span asp-validation-for="TypeId" class="text-danger"></span>
</div>
@Html.Hidden("VenueRefernce", Model.VenueReference)
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>

View File

@ -0,0 +1,45 @@
@model ThAmCo.Events.Data.Event
@{
ViewData["Title"] = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Event</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Title)
</dt>
<dd>
@Html.DisplayFor(model => model.Title)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Date)
</dt>
<dd>
@Html.DisplayFor(model => model.Date)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Duration)
</dt>
<dd>
@Html.DisplayFor(model => model.Duration)
</dd>
<dt>
@Html.DisplayNameFor(model => model.TypeId)
</dt>
<dd>
@Html.DisplayFor(model => model.TypeId)
</dd>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="Id" />
<input type="submit" value="Delete" class="btn btn-default" /> |
<a asp-action="Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,251 @@
@model ThAmCo.Events.Models.EventDetailsModel
@{
ViewData["Title"] = "Details";
}
<h2>Details</h2>
<div>
<h4>Event</h4>
<hr />
<dl class="dl-horizontal venue-details">
<dt>
@Html.DisplayNameFor(model => model.Title)
</dt>
<dd>
@Html.DisplayFor(model => model.Title)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Date)
</dt>
<dd>
@Html.DisplayFor(model => model.Date)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Duration)
</dt>
<dd>
@Html.DisplayFor(model => model.Duration)
</dd>
<dt>
@Html.DisplayNameFor(model => model.TypeId)
</dt>
<dd>
@Html.DisplayFor(model => model.TypeId)
</dd>
</dl>
<dl class="dl-horizontal venue-details">
<dt>
<h4><b><u>@Html.DisplayNameFor(model => model.Reservation)</u></b></h4>
</dt>
@if (Model.Reservation == null)
{
<dd>
<a asp-action="SelectVenue" asp-route-id="@Model.Id">Select Venue</a>
</dd>
}
else
{
<dd></dd>
<dt>
@Html.DisplayNameFor(model => model.Reservation.VenueCode)
</dt>
<dd>
@Html.DisplayFor(model => model.Reservation.VenueCode)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Reservation.EventDate)
</dt>
<dd>
@Html.DisplayFor(model => model.Reservation.EventDate)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Reservation.whenMade)
</dt>
<dd>
@Html.DisplayFor(model => model.Reservation.whenMade)
</dd>
<dt></dt>
<dd>
<a asp-action="FreeReservation" asp-route-id="@Model.Id">Remove Venue</a>
</dd>
}
</dl>
<dl class="dl-horizontal venue-details">
<dt>
<h4><b><u>@Html.DisplayNameFor(model => model.FoodReference)</u></b></h4>
</dt>
@if (Model.FoodReference == 0)
{
<dd>
<a asp-action="AddMenu" asp-route-id="@Model.Id">Select Menu</a>
</dd>
}
else
{
<dd></dd>
<dt>
Menu Number
</dt>
<dd>
@Html.DisplayFor(model => model.FoodReference)
</dd>
}
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |
<a asp-action="Index">Back to List</a>
</div>
<div>
<a asp-action="AddCustomer" asp-route-id="@Model.Id">Add Customer</a>
</div>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Bookings.FirstOrDefault().Customer.Surname)
</th>
<th>
@Html.DisplayNameFor(model => model.Bookings.FirstOrDefault().Customer.FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.Bookings.FirstOrDefault().Customer.Email)
</th>
<th>
@Html.DisplayNameFor(model => model.Bookings.FirstOrDefault().Attended)
</th>
<th>
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Bookings)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Customer.Surname)
</td>
<td>
@Html.DisplayFor(modelItem => item.Customer.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Customer.Email)
</td>
<td>
@Html.DisplayFor(modelItem => item.Attended)
</td>
<td>
<button onclick="toggleAttendance(@item.Customer.Id, @Model.Id)">Toggle Attendance</button>
</td>
<td>
<form asp-action="RemoveCustomer">
<input type="hidden" asp-for="Id" />
@Html.Hidden("EventID", Model.Id)
@Html.Hidden("CustomerID", item.CustomerId)
<input type="submit" value="Remove" />
</form>
</td>
</tr>
}
</tbody>
</table>
Total Attendees: @Model.Bookings.Count
<div>
<a asp-action="AddStaff" asp-route-id="@Model.Id">Add Staff</a>
</div>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Staffing.FirstOrDefault().Staff.Surname)
</th>
<th>
@Html.DisplayNameFor(model => model.Staffing.FirstOrDefault().Staff.FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.Staffing.FirstOrDefault().Staff.Email)
</th>
<th>
@Html.DisplayNameFor(model => model.Staffing.FirstOrDefault().Staff.FirstAid)
</th>
<th>
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Staffing)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Staff.Surname)
</td>
<td>
@Html.DisplayFor(modelItem => item.Staff.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Staff.Email)
</td>
<td>
@Html.DisplayFor(modelItem => item.Staff.FirstAid)
</td>
<td>
<form asp-action="RemoveStaff">
<input type="hidden" asp-for="Id" />
@Html.Hidden("EventID", Model.Id)
@Html.Hidden("StaffID", item.StaffId)
<input type="submit" value="Remove" />
</form>
</td>
</tr>
}
</tbody>
</table>
<h4>
@if (Model.Staffing.Count < Math.Ceiling((double)Model.Bookings.Count / 10))
{
@Html.Raw("&#9888; Only have " + Model.Staffing.Count + " staff members, " + Math.Ceiling((double)Model.Bookings.Count / 10) + " are required. <br>")
}
</h4>
<h4>
@if (Model.Staffing == null || !Model.Staffing.Any(s => s.Staff.FirstAid))
{
@Html.Raw("&#9888; There is no first aid staff member.")
}
</h4>
@section Scripts {
<script type="text/javascript">
function toggleAttendance(cID, eID)
{
$.ajax({
url: "http://localhost:22263/Events/RegisterAttendance?EventId=" + eID + "&CustomerId=" + cID,
type: "POST",
crossDomain: true,
success: function (result) { window.location.reload(false);},
failiure: function () { }
});
}
</script>
}

View File

@ -0,0 +1,39 @@
@model ThAmCo.Events.Data.Event
@{
ViewData["Title"] = "Edit";
}
<h2>Edit</h2>
<h4>Event</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="Title" class="control-label"></label>
<input asp-for="Title" class="form-control" />
<span asp-validation-for="Title" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Duration" class="control-label"></label>
<input asp-for="Duration" class="form-control" />
<span asp-validation-for="Duration" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,30 @@
@model ThAmCo.Events.Models.ViewModels.Events.EventFindVenueModel
@{
ViewData["Title"] = "FindVenue";
}
<h2>FindVenue</h2>
<form asp-action="FindVenueResults">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="EventType" class="control-label"></label>
<input asp-for="EventType" class="form-control" />
<span asp-validation-for="EventType" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="StartDate" class="control-label"></label>
<input type="date" asp-for="StartDate" class="form-control" />
<span asp-validation-for="StartDate" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="EndDate" class="control-label"></label>
<input type="date" asp-for="EndDate" class="form-control" />
<span asp-validation-for="EndDate" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Find Venues" class="btn btn-default" />
</div>
</form>

View File

@ -0,0 +1,60 @@
@model IEnumerable<ThAmCo.Events.Models.VenueDto>
@{
ViewData["Title"] = "FindVenueResults";
}
<h2>FindVenueResults</h2>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().Code)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().Name)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().Capacity)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().Date)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstOrDefault().CostPerHour)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Code)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Capacity)
</td>
<td>
@Html.DisplayFor(modelItem => item.Date)
</td>
<td>
@Html.DisplayFor(modelItem => item.CostPerHour)
</td>
<td>
<form asp-action="CreateReservation">
@Html.Hidden("VenueDate", item.Date)
@Html.Hidden("VenueCode", item.Code)
<input type="submit" value="Reserve" />
</form>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,77 @@
@model IEnumerable<ThAmCo.Events.Data.Event>
@{
ViewData["Title"] = "Index";
}
<h2>Index</h2>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Title)
</th>
<th>
@Html.DisplayNameFor(model => model.Date)
</th>
<th>
@Html.DisplayNameFor(model => model.Duration)
</th>
<th>
@Html.DisplayNameFor(model => model.TypeId)
</th>
<th>
BookingCount
</th>
<th>
VenueReference
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Date)
</td>
<td>
@Html.DisplayFor(modelItem => item.Duration)
</td>
<td>
@Html.DisplayFor(modelItem => item.TypeId)
</td>
<td>
@item.Bookings.Count
</td>
<td>
@Html.DisplayFor(modelItem => item.VenueReference)
</td>
<td>
@if (item.Staffings.Count < Math.Ceiling((double)item.Bookings.Count / 10))
{
@Html.Raw("&#9888; Only have " + item.Staffings.Count + " staff members, " + Math.Ceiling((double)item.Bookings.Count / 10) + " are required.")
}
</td>
<td>
@if (item.Staffings == null || !item.Staffings.Any(s => s.Staff.FirstAid))
{
@Html.Raw("&#9888; There is no first aid staff member.")
}
</td>
<td>
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,59 @@
@model ThAmCo.Events.Models.SelectVenueModel
@{
ViewData["Title"] = "SelectVenue";
}
<h2>SelectVenue</h2>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Venues.FirstOrDefault().Code)
</th>
<th>
@Html.DisplayNameFor(model => model.Venues.FirstOrDefault().Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Venues.FirstOrDefault().Capacity)
</th>
<th>
@Html.DisplayNameFor(model => model.Venues.FirstOrDefault().Date)
</th>
<th>
@Html.DisplayNameFor(model => model.Venues.FirstOrDefault().CostPerHour)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Venues) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Code)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Capacity)
</td>
<td>
@Html.DisplayFor(modelItem => item.Date)
</td>
<td>
@Html.DisplayFor(modelItem => item.CostPerHour)
</td>
<td>
<form asp-action="CreateReservation">
@Html.Hidden("VenueDate", item.Date)
@Html.Hidden("VenueCode", item.Code)
@Html.Hidden("Id", Model.Id)
<input type="submit" value="Reserve" />
</form>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,35 @@
@model ThAmCo.Events.Data.Food
@{
ViewData["Title"] = "Create";
}
<h2>Create</h2>
<h4>Food</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Items" class="control-label"></label>
<input asp-for="Items" class="form-control" />
<span asp-validation-for="Items" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Price" class="control-label"></label>
<input asp-for="Price" class="form-control" />
<span asp-validation-for="Price" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>

View File

@ -0,0 +1,38 @@
@model ThAmCo.Events.Data.Food
@{
ViewData["Title"] = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>Food</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Id)
</dt>
<dd>
@Html.DisplayFor(model => model.Id)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Items)
</dt>
<dd>
@Html.DisplayFor(model => model.Items)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Price)
</dt>
<dd>
@Html.DisplayFor(model => model.Price)
</dd>
</dl>
<form asp-action="Delete">
<input type="submit" value="Delete" class="btn btn-default" /> |
<a asp-action="Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,30 @@
@model ThAmCo.Events.Data.Food
@{
ViewData["Title"] = "Details";
}
<h2>Details</h2>
<div>
<h4>Food</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Items)
</dt>
<dd>
@Html.DisplayFor(model => model.Items)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Price)
</dt>
<dd>
@Html.DisplayFor(model => model.Price)
</dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |
<a asp-action="Index">Back to List</a>
</div>

View File

@ -0,0 +1,36 @@
@model ThAmCo.Events.Data.Food
@{
ViewData["Title"] = "Edit";
}
<h2>Edit</h2>
<h4>Food</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="Items" class="control-label"></label>
<input asp-for="Items" class="form-control" />
<span asp-validation-for="Items" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Price" class="control-label"></label>
<input asp-for="Price" class="form-control" />
<span asp-validation-for="Price" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>

View File

@ -0,0 +1,41 @@
@model IEnumerable<ThAmCo.Events.Data.Food>
@{
ViewData["Title"] = "Index";
}
<h2>Index</h2>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Items)
</th>
<th>
@Html.DisplayNameFor(model => model.Price)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Items)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
</td>
<td>
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
<a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,43 @@
@model ThAmCo.Events.Data.GuestBooking
@{
ViewData["Title"] = "Create";
}
<h2>Create</h2>
<h4>GuestBooking</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="CustomerId" class="control-label"></label>
<select asp-for="CustomerId" class ="form-control" asp-items="ViewBag.CustomerId"></select>
</div>
<div class="form-group">
<label asp-for="EventId" class="control-label"></label>
<select asp-for="EventId" class ="form-control" asp-items="ViewBag.EventId"></select>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="Attended" /> @Html.DisplayNameFor(model => model.Attended)
</label>
</div>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,40 @@
@model ThAmCo.Events.Data.GuestBooking
@{
ViewData["Title"] = "Delete";
}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
<div>
<h4>GuestBooking</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Customer)
</dt>
<dd>
@Html.DisplayFor(model => model.Customer.Email)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Event)
</dt>
<dd>
@Html.DisplayFor(model => model.Event.Title)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Attended)
</dt>
<dd>
@Html.DisplayFor(model => model.Attended)
</dd>
</dl>
<form asp-action="Delete">
<input type="hidden" asp-for="CustomerId" />
<input type="hidden" asp-for="EventId" />
<input type="submit" value="Delete" class="btn btn-default" /> |
<a asp-action="Index">Back to List</a>
</form>
</div>

View File

@ -0,0 +1,36 @@
@model ThAmCo.Events.Data.GuestBooking
@{
ViewData["Title"] = "Details";
}
<h2>Details</h2>
<div>
<h4>GuestBooking</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.Customer)
</dt>
<dd>
@Html.DisplayFor(model => model.Customer.Email)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Event)
</dt>
<dd>
@Html.DisplayFor(model => model.Event.Title)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Attended)
</dt>
<dd>
@Html.DisplayFor(model => model.Attended)
</dd>
</dl>
</div>
<div>
@Html.ActionLink("Edit", "Edit", new { /* id = Model.PrimaryKey */ }) |
<a asp-action="Index">Back to List</a>
</div>

View File

@ -0,0 +1,37 @@
@model ThAmCo.Events.Data.GuestBooking
@{
ViewData["Title"] = "Edit";
}
<h2>Edit</h2>
<h4>GuestBooking</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="CustomerId" />
<input type="hidden" asp-for="EventId" />
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="Attended" /> @Html.DisplayNameFor(model => model.Attended)
</label>
</div>
</div>
<div class="form-group">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

View File

@ -0,0 +1,47 @@
@model IEnumerable<ThAmCo.Events.Data.GuestBooking>
@{
ViewData["Title"] = "Index";
}
<h2>Index</h2>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Customer)
</th>
<th>
@Html.DisplayNameFor(model => model.Event)
</th>
<th>
@Html.DisplayNameFor(model => model.Attended)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Customer.Email)
</td>
<td>
@Html.DisplayFor(modelItem => item.Event.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Attended)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</tbody>
</table>

View File

@ -0,0 +1,7 @@
@{
ViewData["Title"] = "About";
}
<h2>@ViewData["Title"]</h2>
<h3>@ViewData["Message"]</h3>
<p>Use this area to provide additional information.</p>

View File

@ -0,0 +1,17 @@
@{
ViewData["Title"] = "Contact";
}
<h2>@ViewData["Title"]</h2>
<h3>@ViewData["Message"]</h3>
<address>
One Microsoft Way<br />
Redmond, WA 98052-6399<br />
<abbr title="Phone">P:</abbr>
425.555.0100
</address>
<address>
<strong>Support:</strong> <a href="mailto:Support@example.com">Support@example.com</a><br />
<strong>Marketing:</strong> <a href="mailto:Marketing@example.com">Marketing@example.com</a>
</address>

View File

@ -0,0 +1,5 @@
@{
ViewData["Title"] = "Home Page";
}
<h1>ThAmCo Web Apps Home Page.</h1>

View File

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h2>@ViewData["Title"]</h2>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -0,0 +1,22 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
</p>

View File

@ -0,0 +1,41 @@
@using Microsoft.AspNetCore.Http.Features
@{
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
var showBanner = !consentFeature?.CanTrack ?? false;
var cookieString = consentFeature?.CreateConsentCookie();
}
@if (showBanner)
{
<nav id="cookieConsent" class="navbar navbar-default navbar-fixed-top" role="alert">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#cookieConsent .navbar-collapse">
<span class="sr-only">Toggle cookie consent banner</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></span>
</div>
<div class="collapse navbar-collapse">
<p class="navbar-text">
Use this space to summarize your privacy and cookie use policy.
</p>
<div class="navbar-right">
<a asp-controller="Home" asp-action="Privacy" class="btn btn-info navbar-btn">Learn More</a>
<button type="button" class="btn btn-default navbar-btn" data-cookie-string="@cookieString">Accept</button>
</div>
</div>
</div>
</nav>
<script>
(function () {
document.querySelector("#cookieConsent button[data-cookie-string]").addEventListener("click", function (el) {
document.cookie = el.target.dataset.cookieString;
document.querySelector("#cookieConsent").classList.add("hidden");
}, false);
})();
</script>
}

View File

@ -0,0 +1,75 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - ThAmCo.Events</title>
<environment include="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment exclude="Development">
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand">ThAmCo Web Application</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a asp-area="" asp-controller="Customers" asp-action="Index">Customers</a></li>
<li><a asp-area="" asp-controller="Events" asp-action="Index">Events</a></li>
<li><a asp-area="" asp-controller="Staff" asp-action="Index">Staff</a></li>
<li><a asp-are"" asp-controller="Food" asp-action="Index">Food</a></li>
</ul>
</div>
</div>
</nav>
<partial name="_CookieConsentPartial" />
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>&copy; 2018 - ThAmCo.Events</p>
</footer>
</div>
<environment include="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery"
crossorigin="anonymous"
integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
crossorigin="anonymous"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>
@RenderSection("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,18 @@
<environment include="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
<environment exclude="Development">
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.17.0/jquery.validate.min.js"
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator"
crossorigin="anonymous"
integrity="sha384-rZfj/ogBloos6wzLGpPkkOr/gpkBNLZ6b6yLy4o+ok+t/SAKlL5mvXLr0OXNi1Hp">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.9/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
crossorigin="anonymous"
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
</script>
</environment>

View File

@ -0,0 +1,50 @@
@model ThAmCo.Events.Data.Staff
@{
ViewData["Title"] = "Create";
}
<h2>Create</h2>
<h4>Staff</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Surname" class="control-label"></label>
<input asp-for="Surname" class="form-control" />
<span asp-validation-for="Surname" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="FirstName" class="control-label"></label>
<input asp-for="FirstName" class="form-control" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Email" class="control-label"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="FirstAid" /> @Html.DisplayNameFor(model => model.FirstAid)
</label>
</div>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

Some files were not shown because too many files have changed in this diff Show More