diff --git a/CodingEvents/CodingEvents.csproj b/CodingEvents/CodingEvents.csproj
index b775b09..6c57bdb 100644
--- a/CodingEvents/CodingEvents.csproj
+++ b/CodingEvents/CodingEvents.csproj
@@ -6,4 +6,30 @@
enable
+
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
diff --git a/CodingEvents/Controllers/EventCategoryController.cs b/CodingEvents/Controllers/EventCategoryController.cs
new file mode 100644
index 0000000..cff66f9
--- /dev/null
+++ b/CodingEvents/Controllers/EventCategoryController.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using CodingEvents.Data;
+using CodingEvents.Models;
+using CodingEvents.ViewModels;
+using Microsoft.AspNetCore.Mvc;
+
+// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
+
+namespace CodingEvents.Controllers
+{
+ public class EventCategoryController : Controller
+ {
+ private EventDbContext context;
+
+ public EventCategoryController(EventDbContext dbContext)
+ {
+ context = dbContext;
+ }
+
+ // GET: //
+ [HttpGet]
+ public IActionResult Index()
+ {
+ List categories = context.Categories.ToList();
+
+ return View(categories);
+ }
+
+ [HttpGet]
+ [Route("EventCategory/Create")]
+ public IActionResult Create()
+ {
+ AddEventCategoryViewModel addEventCategoryViewModel = new AddEventCategoryViewModel();
+
+ return View(addEventCategoryViewModel);
+ }
+
+ [HttpPost]
+ public IActionResult ProcessCreateEventCategoryForm(AddEventCategoryViewModel addEventCategoryViewModel)
+ {
+ if (ModelState.IsValid)
+ {
+ EventCategory theCategory = new EventCategory
+ {
+ Name = addEventCategoryViewModel.Name
+ };
+
+ context.Categories.Add(theCategory);
+ context.SaveChanges();
+
+ return Redirect("/EventCategory");
+ }
+ return View("Create", addEventCategoryViewModel);
+ }
+ }
+}
+
diff --git a/CodingEvents/Controllers/EventsController.cs b/CodingEvents/Controllers/EventsController.cs
new file mode 100644
index 0000000..865e0ae
--- /dev/null
+++ b/CodingEvents/Controllers/EventsController.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using CodingEvents.Data;
+using CodingEvents.Models;
+using Microsoft.AspNetCore.Mvc;
+using CodingEvents.ViewModels;
+
+// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
+
+namespace CodingEvents.Controllers
+{
+ public class EventsController : Controller
+ {
+ private EventDbContext context;
+
+ public EventsController(EventDbContext dbContext)
+ {
+ context = dbContext;
+ }
+ // GET: //
+ public IActionResult Index()
+ {
+ List events = context.Events.ToList();
+
+ return View(events);
+ }
+
+ [HttpGet]
+ public IActionResult Add()
+ {
+ AddEventViewModel addEventViewModel = new AddEventViewModel();
+
+ return View(addEventViewModel);
+ }
+
+ [HttpPost]
+ public IActionResult Add(AddEventViewModel addEventViewModel)
+ {
+ if (ModelState.IsValid)
+ {
+ Event newEvent = new Event
+ {
+ Name = addEventViewModel.Name,
+ Description = addEventViewModel.Description,
+ ContactEmail = addEventViewModel.ContactEmail,
+ Type = addEventViewModel.Type
+ };
+
+ context.Events.Add(newEvent);
+ context.SaveChanges();
+
+ return Redirect("/Events");
+ }
+
+ return View(addEventViewModel);
+ }
+
+ public IActionResult Delete()
+ {
+ ViewBag.events = context.Events.ToList();
+
+ return View();
+ }
+
+ [HttpPost]
+ public IActionResult Delete(int[] eventIds)
+ {
+ foreach (int eventId in eventIds)
+ {
+ Event? theEvent = context.Events.Find(eventId);
+ context.Events.Remove(theEvent);
+ }
+
+ context.SaveChanges();
+
+ return Redirect("/Events");
+ }
+ }
+}
+
diff --git a/CodingEvents/Data/EventDbContext.cs b/CodingEvents/Data/EventDbContext.cs
new file mode 100644
index 0000000..a5323d3
--- /dev/null
+++ b/CodingEvents/Data/EventDbContext.cs
@@ -0,0 +1,18 @@
+using System;
+using CodingEvents.Models;
+using Microsoft.EntityFrameworkCore;
+
+namespace CodingEvents.Data
+{
+ public class EventDbContext : DbContext
+ {
+ public DbSet Events { get; set; }
+ public DbSet Categories { get; set; }
+
+
+ public EventDbContext(DbContextOptions options) : base(options)
+ {
+ }
+ }
+}
+
diff --git a/CodingEvents/Migrations/20230308200850_InitialMigration.Designer.cs b/CodingEvents/Migrations/20230308200850_InitialMigration.Designer.cs
new file mode 100644
index 0000000..65fe7d5
--- /dev/null
+++ b/CodingEvents/Migrations/20230308200850_InitialMigration.Designer.cs
@@ -0,0 +1,46 @@
+//
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ [DbContext(typeof(EventDbContext))]
+ [Migration("20230308200850_InitialMigration")]
+ partial class InitialMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("CodingEvents.Models.Event", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("ContactEmail")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Events");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308200850_InitialMigration.cs b/CodingEvents/Migrations/20230308200850_InitialMigration.cs
new file mode 100644
index 0000000..254227c
--- /dev/null
+++ b/CodingEvents/Migrations/20230308200850_InitialMigration.cs
@@ -0,0 +1,44 @@
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ ///
+ public partial class InitialMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterDatabase()
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Events",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ Name = table.Column(type: "longtext", nullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ Description = table.Column(type: "longtext", nullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ ContactEmail = table.Column(type: "longtext", nullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Events", x => x.Id);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Events");
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308201656_ContextAddedMigration.Designer.cs b/CodingEvents/Migrations/20230308201656_ContextAddedMigration.Designer.cs
new file mode 100644
index 0000000..7e602e4
--- /dev/null
+++ b/CodingEvents/Migrations/20230308201656_ContextAddedMigration.Designer.cs
@@ -0,0 +1,46 @@
+//
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ [DbContext(typeof(EventDbContext))]
+ [Migration("20230308201656_ContextAddedMigration")]
+ partial class ContextAddedMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("CodingEvents.Models.Event", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("ContactEmail")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Events");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308201656_ContextAddedMigration.cs b/CodingEvents/Migrations/20230308201656_ContextAddedMigration.cs
new file mode 100644
index 0000000..1db35fd
--- /dev/null
+++ b/CodingEvents/Migrations/20230308201656_ContextAddedMigration.cs
@@ -0,0 +1,22 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ ///
+ public partial class ContextAddedMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308202707_EventCategoryDbMigration.Designer.cs b/CodingEvents/Migrations/20230308202707_EventCategoryDbMigration.Designer.cs
new file mode 100644
index 0000000..7dea4cb
--- /dev/null
+++ b/CodingEvents/Migrations/20230308202707_EventCategoryDbMigration.Designer.cs
@@ -0,0 +1,60 @@
+//
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ [DbContext(typeof(EventDbContext))]
+ [Migration("20230308202707_EventCategoryDbMigration")]
+ partial class EventCategoryDbMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("CodingEvents.Models.Event", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("ContactEmail")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Events");
+ });
+
+ modelBuilder.Entity("CodingEvents.Models.EventCategory", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Categories");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308202707_EventCategoryDbMigration.cs b/CodingEvents/Migrations/20230308202707_EventCategoryDbMigration.cs
new file mode 100644
index 0000000..04d7f14
--- /dev/null
+++ b/CodingEvents/Migrations/20230308202707_EventCategoryDbMigration.cs
@@ -0,0 +1,37 @@
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ ///
+ public partial class EventCategoryDbMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Categories",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ Name = table.Column(type: "longtext", nullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Categories", x => x.Id);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Categories");
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308204054_EnumsCodeAddedMigration.Designer.cs b/CodingEvents/Migrations/20230308204054_EnumsCodeAddedMigration.Designer.cs
new file mode 100644
index 0000000..84b256b
--- /dev/null
+++ b/CodingEvents/Migrations/20230308204054_EnumsCodeAddedMigration.Designer.cs
@@ -0,0 +1,63 @@
+//
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ [DbContext(typeof(EventDbContext))]
+ [Migration("20230308204054_EnumsCodeAddedMigration")]
+ partial class EnumsCodeAddedMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("CodingEvents.Models.Event", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("ContactEmail")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.Property("Type")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Events");
+ });
+
+ modelBuilder.Entity("CodingEvents.Models.EventCategory", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Categories");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308204054_EnumsCodeAddedMigration.cs b/CodingEvents/Migrations/20230308204054_EnumsCodeAddedMigration.cs
new file mode 100644
index 0000000..5d748c5
--- /dev/null
+++ b/CodingEvents/Migrations/20230308204054_EnumsCodeAddedMigration.cs
@@ -0,0 +1,29 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ ///
+ public partial class EnumsCodeAddedMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "Type",
+ table: "Events",
+ type: "int",
+ nullable: false,
+ defaultValue: 0);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Type",
+ table: "Events");
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308211501_EventCategoryAddedMigration.Designer.cs b/CodingEvents/Migrations/20230308211501_EventCategoryAddedMigration.Designer.cs
new file mode 100644
index 0000000..6bdd46c
--- /dev/null
+++ b/CodingEvents/Migrations/20230308211501_EventCategoryAddedMigration.Designer.cs
@@ -0,0 +1,63 @@
+//
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ [DbContext(typeof(EventDbContext))]
+ [Migration("20230308211501_EventCategoryAddedMigration")]
+ partial class EventCategoryAddedMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("CodingEvents.Models.Event", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("ContactEmail")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.Property("Type")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Events");
+ });
+
+ modelBuilder.Entity("CodingEvents.Models.EventCategory", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Categories");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308211501_EventCategoryAddedMigration.cs b/CodingEvents/Migrations/20230308211501_EventCategoryAddedMigration.cs
new file mode 100644
index 0000000..93dcc62
--- /dev/null
+++ b/CodingEvents/Migrations/20230308211501_EventCategoryAddedMigration.cs
@@ -0,0 +1,22 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ ///
+ public partial class EventCategoryAddedMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308213444_EventCategoryUpdateMigration.Designer.cs b/CodingEvents/Migrations/20230308213444_EventCategoryUpdateMigration.Designer.cs
new file mode 100644
index 0000000..eaefb39
--- /dev/null
+++ b/CodingEvents/Migrations/20230308213444_EventCategoryUpdateMigration.Designer.cs
@@ -0,0 +1,63 @@
+//
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ [DbContext(typeof(EventDbContext))]
+ [Migration("20230308213444_EventCategoryUpdateMigration")]
+ partial class EventCategoryUpdateMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("CodingEvents.Models.Event", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("ContactEmail")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.Property("Type")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Events");
+ });
+
+ modelBuilder.Entity("CodingEvents.Models.EventCategory", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Categories");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230308213444_EventCategoryUpdateMigration.cs b/CodingEvents/Migrations/20230308213444_EventCategoryUpdateMigration.cs
new file mode 100644
index 0000000..f3aa4a7
--- /dev/null
+++ b/CodingEvents/Migrations/20230308213444_EventCategoryUpdateMigration.cs
@@ -0,0 +1,22 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ ///
+ public partial class EventCategoryUpdateMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230315185642_InitialMigration-NewDB.Designer.cs b/CodingEvents/Migrations/20230315185642_InitialMigration-NewDB.Designer.cs
new file mode 100644
index 0000000..410a877
--- /dev/null
+++ b/CodingEvents/Migrations/20230315185642_InitialMigration-NewDB.Designer.cs
@@ -0,0 +1,63 @@
+//
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ [DbContext(typeof(EventDbContext))]
+ [Migration("20230315185642_InitialMigration-NewDB")]
+ partial class InitialMigrationNewDB
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("CodingEvents.Models.Event", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("ContactEmail")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.Property("Type")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Events");
+ });
+
+ modelBuilder.Entity("CodingEvents.Models.EventCategory", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Categories");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230315185642_InitialMigration-NewDB.cs b/CodingEvents/Migrations/20230315185642_InitialMigration-NewDB.cs
new file mode 100644
index 0000000..49d6c47
--- /dev/null
+++ b/CodingEvents/Migrations/20230315185642_InitialMigration-NewDB.cs
@@ -0,0 +1,22 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ ///
+ public partial class InitialMigrationNewDB : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230315190856_DBCheck.Designer.cs b/CodingEvents/Migrations/20230315190856_DBCheck.Designer.cs
new file mode 100644
index 0000000..ebbe326
--- /dev/null
+++ b/CodingEvents/Migrations/20230315190856_DBCheck.Designer.cs
@@ -0,0 +1,63 @@
+//
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ [DbContext(typeof(EventDbContext))]
+ [Migration("20230315190856_DBCheck")]
+ partial class DBCheck
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("CodingEvents.Models.Event", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("ContactEmail")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.Property("Type")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Events");
+ });
+
+ modelBuilder.Entity("CodingEvents.Models.EventCategory", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Categories");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/20230315190856_DBCheck.cs b/CodingEvents/Migrations/20230315190856_DBCheck.cs
new file mode 100644
index 0000000..ae767c7
--- /dev/null
+++ b/CodingEvents/Migrations/20230315190856_DBCheck.cs
@@ -0,0 +1,22 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ ///
+ public partial class DBCheck : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+
+ }
+ }
+}
diff --git a/CodingEvents/Migrations/EventDbContextModelSnapshot.cs b/CodingEvents/Migrations/EventDbContextModelSnapshot.cs
new file mode 100644
index 0000000..ec479bd
--- /dev/null
+++ b/CodingEvents/Migrations/EventDbContextModelSnapshot.cs
@@ -0,0 +1,60 @@
+//
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CodingEvents.Migrations
+{
+ [DbContext(typeof(EventDbContext))]
+ partial class EventDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("CodingEvents.Models.Event", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("ContactEmail")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.Property("Type")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Events");
+ });
+
+ modelBuilder.Entity("CodingEvents.Models.EventCategory", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Categories");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/CodingEvents/Models/Event.cs b/CodingEvents/Models/Event.cs
new file mode 100644
index 0000000..e42ccab
--- /dev/null
+++ b/CodingEvents/Models/Event.cs
@@ -0,0 +1,39 @@
+using System;
+namespace CodingEvents.Models
+{
+ public class Event
+ {
+ public string? Name { get; set; }
+ public string? Description { get; set; }
+ public string? ContactEmail { get; set; }
+ public EventType Type { get; set; }
+
+ public int Id { get; set; }
+
+ public Event()
+ {
+ }
+
+ public Event(string name, string description, string contactEmail)
+ {
+ Name = name;
+ Description = description;
+ ContactEmail = contactEmail;
+ }
+
+ public override string? ToString()
+ {
+ return Name;
+ }
+
+ public override bool Equals(object? obj)
+ {
+ return obj is Event @event && Id == @event.Id;
+ }
+
+ public override int GetHashCode()
+ {
+ return HashCode.Combine(Id);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CodingEvents/Models/EventCategory.cs b/CodingEvents/Models/EventCategory.cs
new file mode 100644
index 0000000..d3a294a
--- /dev/null
+++ b/CodingEvents/Models/EventCategory.cs
@@ -0,0 +1,20 @@
+using System;
+namespace CodingEvents.Models
+{
+ public class EventCategory
+ {
+ public int Id { get; set; }
+ public string? Name { get; set; }
+
+
+ public EventCategory()
+ {
+ }
+
+ public EventCategory(string name)
+ {
+ Name = name;
+ }
+ }
+}
+
diff --git a/CodingEvents/Models/EventType.cs b/CodingEvents/Models/EventType.cs
new file mode 100644
index 0000000..fa25a82
--- /dev/null
+++ b/CodingEvents/Models/EventType.cs
@@ -0,0 +1,12 @@
+using System;
+namespace CodingEvents.Models
+{
+ public enum EventType
+ {
+ Conference,
+ Meetup,
+ Workshop,
+ Social
+ }
+}
+
diff --git a/CodingEvents/Program.cs b/CodingEvents/Program.cs
index 9fbb57d..9425427 100644
--- a/CodingEvents/Program.cs
+++ b/CodingEvents/Program.cs
@@ -1,8 +1,16 @@
-var builder = WebApplication.CreateBuilder(args);
+using CodingEvents.Data;
+using Microsoft.EntityFrameworkCore;
+
+var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
+var connectionString = "server=localhost;user=test-user;password=test-user;database=coding-events";
+var serverVersion = new MySqlServerVersion(new Version(8, 0,29));
+
+builder.Services.AddDbContext(dbContextOptions => dbContextOptions.UseMySql(connectionString, serverVersion));
+
var app = builder.Build();
// Configure the HTTP request pipeline.
diff --git a/CodingEvents/Properties/launchSettings.json b/CodingEvents/Properties/launchSettings.json
index f91f5dd..6c90c7e 100644
--- a/CodingEvents/Properties/launchSettings.json
+++ b/CodingEvents/Properties/launchSettings.json
@@ -11,7 +11,7 @@
"CodingEvents": {
"commandName": "Project",
"launchBrowser": true,
- "applicationUrl": "https://localhost:7029;http://localhost:5015",
+ "applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
diff --git a/CodingEvents/ViewModels/AddEventCategoryViewModel.cs b/CodingEvents/ViewModels/AddEventCategoryViewModel.cs
new file mode 100644
index 0000000..2fb4d82
--- /dev/null
+++ b/CodingEvents/ViewModels/AddEventCategoryViewModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+
+namespace CodingEvents.ViewModels
+{
+ public class AddEventCategoryViewModel
+ {
+ [Required(ErrorMessage ="Please add a category type")]
+ [StringLength(20, MinimumLength =1, ErrorMessage ="Category type should be between 1-20 characters")]
+ public string? Name { get; set; }
+ }
+}
+
diff --git a/CodingEvents/ViewModels/AddEventViewModel.cs b/CodingEvents/ViewModels/AddEventViewModel.cs
new file mode 100644
index 0000000..68ee651
--- /dev/null
+++ b/CodingEvents/ViewModels/AddEventViewModel.cs
@@ -0,0 +1,31 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using CodingEvents.Models;
+using Microsoft.AspNetCore.Mvc.Rendering;
+
+namespace CodingEvents.ViewModels
+{
+ public class AddEventViewModel
+ {
+ [Required(ErrorMessage = "Name is required.")]
+ [StringLength(50, MinimumLength = 3, ErrorMessage = "Name must be between 3 and 50 characters.")]
+ public string? Name { get; set; }
+
+ [Required(ErrorMessage = "Please enter a description for your event.")]
+ [StringLength(500, ErrorMessage = "Description is too long!")]
+ public string? Description { get; set; }
+
+ [EmailAddress]
+ public string? ContactEmail { get; set; }
+
+ public EventType Type { get; set; }
+
+ public List EventTypes { get; set; } = new List
+ {
+ new SelectListItem(EventType.Conference.ToString(), ((int)EventType.Conference).ToString()),
+ new SelectListItem(EventType.Meetup.ToString(), ((int)EventType.Meetup).ToString()),
+ new SelectListItem(EventType.Social.ToString(), ((int)EventType.Social).ToString()),
+ new SelectListItem(EventType.Workshop.ToString(), ((int)EventType.Workshop).ToString())
+ };
+ }
+}
diff --git a/CodingEvents/Views/EventCategory/Create.cshtml b/CodingEvents/Views/EventCategory/Create.cshtml
new file mode 100644
index 0000000..0ae0aa3
--- /dev/null
+++ b/CodingEvents/Views/EventCategory/Create.cshtml
@@ -0,0 +1,12 @@
+@model CodingEvents.ViewModels.AddEventCategoryViewModel
+
+Add New Category
+
+
\ No newline at end of file
diff --git a/CodingEvents/Views/EventCategory/Index.cshtml b/CodingEvents/Views/EventCategory/Index.cshtml
new file mode 100644
index 0000000..41af2f8
--- /dev/null
+++ b/CodingEvents/Views/EventCategory/Index.cshtml
@@ -0,0 +1,24 @@
+@model List
+
+All Event Categories
+
+@if (Model.Count == 0)
+{
+ No Event Categories yet!
+}
+else
+{
+
+
+ | Id
+ | Category Name |
+
+ @foreach (EventCategory category in Model)
+ {
+
+ | @category.Id |
+ @category.Name |
+
+ }
+
+}
\ No newline at end of file
diff --git a/CodingEvents/Views/Events/Add.cshtml b/CodingEvents/Views/Events/Add.cshtml
new file mode 100644
index 0000000..8fb89be
--- /dev/null
+++ b/CodingEvents/Views/Events/Add.cshtml
@@ -0,0 +1,27 @@
+@using CodingEvents.ViewModels
+@model AddEventViewModel
+
+Add Event
+
+
\ No newline at end of file
diff --git a/CodingEvents/Views/Events/Delete.cshtml b/CodingEvents/Views/Events/Delete.cshtml
new file mode 100644
index 0000000..1b7564c
--- /dev/null
+++ b/CodingEvents/Views/Events/Delete.cshtml
@@ -0,0 +1,21 @@
+@*
+ For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
+*@
+@{
+}
+
+Delete Event
+
+
diff --git a/CodingEvents/Views/Events/Index.cshtml b/CodingEvents/Views/Events/Index.cshtml
new file mode 100644
index 0000000..9bbcff6
--- /dev/null
+++ b/CodingEvents/Views/Events/Index.cshtml
@@ -0,0 +1,49 @@
+@using CodingEvents.Models
+@model List
+
+Coding Events
+
+
+ Add Event
+
+
+
+ Delete Event
+
+
+@if (Model.Count == 0)
+{
+ No events yet!
+}
+else
+{
+
+
+ |
+ Id
+ |
+
+ Name
+ |
+
+ Description
+ |
+
+ Contact Email
+ |
+
+ Event Type
+ |
+
+ @foreach (var evt in Model)
+ {
+
+ | @evt.Id |
+ @evt.Name |
+ @evt.Description |
+ @evt.ContactEmail |
+ @evt.Type |
+
+ }
+
+}
\ No newline at end of file
diff --git a/CodingEvents/Views/Shared/_Layout.cshtml b/CodingEvents/Views/Shared/_Layout.cshtml
index 97c916e..9480a7f 100644
--- a/CodingEvents/Views/Shared/_Layout.cshtml
+++ b/CodingEvents/Views/Shared/_Layout.cshtml
@@ -12,7 +12,7 @@