diff --git a/CodingEventsDemo/CodingEventsDemo.csproj b/CodingEventsDemo/CodingEventsDemo.csproj index 1992ad14..fd84e9e3 100644 --- a/CodingEventsDemo/CodingEventsDemo.csproj +++ b/CodingEventsDemo/CodingEventsDemo.csproj @@ -1,12 +1,32 @@ - netcoreapp3.1 + net6.0 + + + + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + diff --git a/CodingEventsDemo/Controllers/EventsController.cs b/CodingEventsDemo/Controllers/EventsController.cs index 16edaf58..9ae97a94 100644 --- a/CodingEventsDemo/Controllers/EventsController.cs +++ b/CodingEventsDemo/Controllers/EventsController.cs @@ -2,6 +2,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using CodingEventsDemo.Data; +using CodingEventsDemo.Models; +using CodingEventsDemo.ViewModels; using Microsoft.AspNetCore.Mvc; // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 @@ -10,27 +13,69 @@ namespace coding_events_practice.Controllers { public class EventsController : Controller { + //17.3 + private EventDbContext context; - static private List Events = new List(); + //17.3 + public EventsController(EventDbContext dbContext) + { + context = dbContext; + } // GET: // public IActionResult Index() { - ViewBag.events = Events; + List events = context.Events.ToList(); - return View(); + return View(events); } public IActionResult Add() { - return View(); + AddEventViewModel addEventViewModel = new AddEventViewModel(); + return View(addEventViewModel); } [HttpPost] [Route("Events/Add")] - public IActionResult NewEvent(string name) + public IActionResult Add(AddEventViewModel addEventViewModel) + { + if (ModelState.IsValid) + { + Event newEvent = new Event + { + Name = addEventViewModel.Name, + Description = addEventViewModel.Description, + ContactEmail = addEventViewModel.ContactEmail, + Type = addEventViewModel.Type + }; + //need to add the context + 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) { - Events.Add(name); + foreach (int eventId in eventIds) + { + Event theEvent = context.Events.Find(eventId); + context.Events.Remove(theEvent); + } + + context.SaveChanges(); return Redirect("/Events"); } diff --git a/CodingEventsDemo/Data/EventData.cs b/CodingEventsDemo/Data/EventData.cs new file mode 100644 index 00000000..681016ab --- /dev/null +++ b/CodingEventsDemo/Data/EventData.cs @@ -0,0 +1,41 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using CodingEventsDemo.Models; + +//namespace CodingEventsDemo.Data +//{ +// public class EventData +// { +// //Events => Event +// static private Dictionary Events = new Dictionary(); + +// // GetAll +// public static IEnumerable GetAll() +// { +// return Events.Values; +// } + +// // Add +// public static void Add(Event newEvent) +// { +// Events.Add(newEvent.ID, newEvent); +// Console.WriteLine(newEvent.ID); +// } + +// // Remove +// public static void Remove(int id) +// { +// Events.Remove(id); +// } + +// // GetById +// public static Event GetById(int id) +// { +// return Events[id]; +// } +// } +//} + + +// ---- no longer needed once we get to 17.3 \ No newline at end of file diff --git a/CodingEventsDemo/Data/EventDbContext.cs b/CodingEventsDemo/Data/EventDbContext.cs new file mode 100644 index 00000000..0b5a6fea --- /dev/null +++ b/CodingEventsDemo/Data/EventDbContext.cs @@ -0,0 +1,20 @@ +using System; +using CodingEventsDemo.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Hosting; +//using static Google.Protobuf.Collections.MapField; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; +//created in 17.2 + +namespace CodingEventsDemo.Data +{ + public class EventDbContext : DbContext + { + public DbSet Events { get; set; } + + public EventDbContext(DbContextOptions options) + : base(options) + { + } + } +} diff --git a/CodingEventsDemo/Migrations/20221109212821_AgainMigrating.Designer.cs b/CodingEventsDemo/Migrations/20221109212821_AgainMigrating.Designer.cs new file mode 100644 index 00000000..d5448e57 --- /dev/null +++ b/CodingEventsDemo/Migrations/20221109212821_AgainMigrating.Designer.cs @@ -0,0 +1,48 @@ +// +using CodingEventsDemo.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CodingEventsDemo.Migrations +{ + [DbContext(typeof(EventDbContext))] + [Migration("20221109212821_AgainMigrating")] + partial class AgainMigrating + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("CodingEventsDemo.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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CodingEventsDemo/Migrations/20221109212821_AgainMigrating.cs b/CodingEventsDemo/Migrations/20221109212821_AgainMigrating.cs new file mode 100644 index 00000000..7df017c3 --- /dev/null +++ b/CodingEventsDemo/Migrations/20221109212821_AgainMigrating.cs @@ -0,0 +1,42 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CodingEventsDemo.Migrations +{ + public partial class AgainMigrating : 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"), + Type = table.Column(type: "int", nullable: false) + }, + 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/CodingEventsDemo/Migrations/20221109215108_AgainMigrating4.Designer.cs b/CodingEventsDemo/Migrations/20221109215108_AgainMigrating4.Designer.cs new file mode 100644 index 00000000..4bce3fcd --- /dev/null +++ b/CodingEventsDemo/Migrations/20221109215108_AgainMigrating4.Designer.cs @@ -0,0 +1,47 @@ +// +using CodingEventsDemo.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CodingEventsDemo.Migrations +{ + [DbContext(typeof(EventDbContext))] + [Migration("20221109215108_AgainMigrating4")] + partial class AgainMigrating4 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("CodingEventsDemo.Models.Event", b => + { + b.Property("ID") + .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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CodingEventsDemo/Migrations/20221109215108_AgainMigrating4.cs b/CodingEventsDemo/Migrations/20221109215108_AgainMigrating4.cs new file mode 100644 index 00000000..6a94afab --- /dev/null +++ b/CodingEventsDemo/Migrations/20221109215108_AgainMigrating4.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CodingEventsDemo.Migrations +{ + public partial class AgainMigrating4 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ID", + table: "Events", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ID", + table: "Events", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + } + } +} diff --git a/CodingEventsDemo/Migrations/20221109215305_AgainMigrating5.Designer.cs b/CodingEventsDemo/Migrations/20221109215305_AgainMigrating5.Designer.cs new file mode 100644 index 00000000..120eac03 --- /dev/null +++ b/CodingEventsDemo/Migrations/20221109215305_AgainMigrating5.Designer.cs @@ -0,0 +1,48 @@ +// +using CodingEventsDemo.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CodingEventsDemo.Migrations +{ + [DbContext(typeof(EventDbContext))] + [Migration("20221109215305_AgainMigrating5")] + partial class AgainMigrating5 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("CodingEventsDemo.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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CodingEventsDemo/Migrations/20221109215305_AgainMigrating5.cs b/CodingEventsDemo/Migrations/20221109215305_AgainMigrating5.cs new file mode 100644 index 00000000..26b768ec --- /dev/null +++ b/CodingEventsDemo/Migrations/20221109215305_AgainMigrating5.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CodingEventsDemo.Migrations +{ + public partial class AgainMigrating5 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ID", + table: "Events", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ID", + table: "Events", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + } + } +} diff --git a/CodingEventsDemo/Migrations/20221110153011_NewMigration12.Designer.cs b/CodingEventsDemo/Migrations/20221110153011_NewMigration12.Designer.cs new file mode 100644 index 00000000..03a64ca4 --- /dev/null +++ b/CodingEventsDemo/Migrations/20221110153011_NewMigration12.Designer.cs @@ -0,0 +1,48 @@ +// +using CodingEventsDemo.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CodingEventsDemo.Migrations +{ + [DbContext(typeof(EventDbContext))] + [Migration("20221110153011_NewMigration12")] + partial class NewMigration12 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("CodingEventsDemo.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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CodingEventsDemo/Migrations/20221110153011_NewMigration12.cs b/CodingEventsDemo/Migrations/20221110153011_NewMigration12.cs new file mode 100644 index 00000000..e809f24f --- /dev/null +++ b/CodingEventsDemo/Migrations/20221110153011_NewMigration12.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CodingEventsDemo.Migrations +{ + public partial class NewMigration12 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/CodingEventsDemo/Migrations/EventDbContextModelSnapshot.cs b/CodingEventsDemo/Migrations/EventDbContextModelSnapshot.cs new file mode 100644 index 00000000..45f6007b --- /dev/null +++ b/CodingEventsDemo/Migrations/EventDbContextModelSnapshot.cs @@ -0,0 +1,46 @@ +// +using CodingEventsDemo.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CodingEventsDemo.Migrations +{ + [DbContext(typeof(EventDbContext))] + partial class EventDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("CodingEventsDemo.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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CodingEventsDemo/Models/Event.cs b/CodingEventsDemo/Models/Event.cs new file mode 100644 index 00000000..9902096e --- /dev/null +++ b/CodingEventsDemo/Models/Event.cs @@ -0,0 +1,49 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.AspNetCore.Mvc; + +namespace CodingEventsDemo.Models +{ + public class Event + { + public int ID { get; set; } + + public string Name { get; set; } + + public string Description { get; set; } + + public string ContactEmail { get; set; } + + public EventType Type { 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 @e && + ID == @e.ID; + } + + public override int GetHashCode() + { + return HashCode.Combine(ID); + } + } +} \ No newline at end of file diff --git a/CodingEventsDemo/Models/EventType.cs b/CodingEventsDemo/Models/EventType.cs new file mode 100644 index 00000000..740eb8e0 --- /dev/null +++ b/CodingEventsDemo/Models/EventType.cs @@ -0,0 +1,12 @@ +using System; +namespace CodingEventsDemo.Models +{ + public enum EventType + { + Conference, + Meetup, + Workshop, + Social + } +} + diff --git a/CodingEventsDemo/Properties/launchSettings.json b/CodingEventsDemo/Properties/launchSettings.json index 292641b9..f20d8641 100644 --- a/CodingEventsDemo/Properties/launchSettings.json +++ b/CodingEventsDemo/Properties/launchSettings.json @@ -1,7 +1,7 @@ -{ +{ "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, + "windowsAuthentication": false, + "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:45981", "sslPort": 44368 @@ -18,10 +18,10 @@ "CodingEventsDemo": { "commandName": "Project", "launchBrowser": true, - "applicationUrl": "https://localhost:5001;http://localhost:5000", + "applicationUrl": "http://localhost:5168", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } -} +} \ No newline at end of file diff --git a/CodingEventsDemo/Startup.cs b/CodingEventsDemo/Startup.cs index 342d7328..989a937a 100644 --- a/CodingEventsDemo/Startup.cs +++ b/CodingEventsDemo/Startup.cs @@ -2,12 +2,17 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using CodingEventsDemo.Data; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +//using MySql.Data.EntityFrameworkCore; namespace CodingEventsDemo { @@ -24,6 +29,12 @@ public Startup(IConfiguration configuration) public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); + + var serverVersion = new MySqlServerVersion(new Version(8, 0, 29)); + var connectionString = "server=localhost;user=NewCodingEventsDemo;password=NewCodingEventsDemo;database=NewCodingEventsDemo"; + + services.AddDbContext(options => + options.UseMySql(connectionString, serverVersion)); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/CodingEventsDemo/ViewModels/AddEventViewModel.cs b/CodingEventsDemo/ViewModels/AddEventViewModel.cs new file mode 100644 index 00000000..ceaf9f89 --- /dev/null +++ b/CodingEventsDemo/ViewModels/AddEventViewModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using CodingEventsDemo.Models; +using Microsoft.AspNetCore.Mvc.Rendering; + +namespace CodingEventsDemo.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 = "Description is required")] + [StringLength(500, ErrorMessage = "Description 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()) + }; + + } +} \ No newline at end of file diff --git a/CodingEventsDemo/Views/Events/Add.cshtml b/CodingEventsDemo/Views/Events/Add.cshtml index 0010854d..b3dcaa90 100644 --- a/CodingEventsDemo/Views/Events/Add.cshtml +++ b/CodingEventsDemo/Views/Events/Add.cshtml @@ -1,6 +1,28 @@ -Add Event +@using CodingEventsDemo.ViewModels; +@model AddEventViewModel; + + +Add Event - + + + + + + + + + + + + Contact Email + + + + + Event Type + + diff --git a/CodingEventsDemo/Views/Events/Delete.cshtml b/CodingEventsDemo/Views/Events/Delete.cshtml new file mode 100644 index 00000000..1bd32e97 --- /dev/null +++ b/CodingEventsDemo/Views/Events/Delete.cshtml @@ -0,0 +1,22 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} + +Delete Event + + + @foreach (var evt in ViewBag.events) + { + + + @evt.Name + + + + } + + + + diff --git a/CodingEventsDemo/Views/Events/Index.cshtml b/CodingEventsDemo/Views/Events/Index.cshtml index 7278447c..5da73954 100644 --- a/CodingEventsDemo/Views/Events/Index.cshtml +++ b/CodingEventsDemo/Views/Events/Index.cshtml @@ -1,17 +1,50 @@ -Coding Events +@model List + +Coding Events Add Event -@if (ViewBag.events.Count == 0) + + + Delete Event + + +@if (Model.Count == 0) { No events yet! } +else +{ + + + + Id + + + Name + + + Description + + + Contact Email + + + Type + + + @foreach (var evt in Model) + { + + @evt.ID + @evt.Name + @evt.Description + @evt.ContactEmail + @evt.Type + + } + +} - - @foreach (string meeting in ViewBag.events) - { - @meeting - } - diff --git a/CodingEventsDemo/Views/Shared/_Layout.cshtml b/CodingEventsDemo/Views/Shared/_Layout.cshtml index 36ea09b8..4f92667b 100644 --- a/CodingEventsDemo/Views/Shared/_Layout.cshtml +++ b/CodingEventsDemo/Views/Shared/_Layout.cshtml @@ -3,7 +3,7 @@ - @ViewData["Title"] - CodingEventsDemo + @ViewData["Title"] - Coding Events @@ -11,7 +11,7 @@ - CodingEventsDemo + CodingEventsDemo @@ -19,10 +19,7 @@ - Home - - - Privacy + Add @@ -32,6 +29,13 @@ @RenderBody() + @*adding this -----*@ + @*source: https://learn.microsoft.com/en-us/aspnet/core/mvc/models/validation?view=aspnetcore-6.0#client-side-validation*@ + + + + @*adding this up here ----*@ + diff --git a/CodingEventsDemo/appsettings.Development.json b/CodingEventsDemo/appsettings.Development.json index 8983e0fc..222224e3 100644 --- a/CodingEventsDemo/appsettings.Development.json +++ b/CodingEventsDemo/appsettings.Development.json @@ -5,5 +5,6 @@ "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } - } -} + }, + "AllowedHosts": "*" +} \ No newline at end of file diff --git a/CodingEventsDemo/appsettings.json b/CodingEventsDemo/appsettings.json index d9d9a9bf..9ddb36ec 100644 --- a/CodingEventsDemo/appsettings.json +++ b/CodingEventsDemo/appsettings.json @@ -6,5 +6,9 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "ConnectionStrings": { + "DefaultConnection": "server=localhost;userid=NewCodingEventsDemo;password=NewCodingEventsDemo;database=NewCodingEventsDemo;" + + } } diff --git a/CodingEventsDemo/wwwroot/css/site.css b/CodingEventsDemo/wwwroot/css/site.css index e679a8ea..edf59a72 100644 --- a/CodingEventsDemo/wwwroot/css/site.css +++ b/CodingEventsDemo/wwwroot/css/site.css @@ -69,3 +69,22 @@ body { white-space: nowrap; line-height: 60px; /* Vertically center the text there */ } + +.validation-summary-errors { + border: 2px solid red; + color: red; + font-weight: bold; + margin: 6px; + width: 30%; +} +.field-validation-error { + color: red; + font-weight: bold; + background-color: yellow; +} + +.input-validation-error { + color: red; + font-weight: bold; + background-color: pink; +} \ No newline at end of file
Add Event
+ Delete Event +
No events yet!