From b5f2c2eae4b81453977b719013813608c0f53fca Mon Sep 17 00:00:00 2001 From: "Daniel Mackay [SSW]" <2636640+danielmackay@users.noreply.github.com> Date: Tue, 21 Nov 2023 16:20:30 +1000 Subject: [PATCH] Removed commented out code and fixed warnings. --- .../CreateCustomerCommandValidator.cs | 3 --- .../UpdateCustomerCommandValidator.cs | 16 ---------------- .../EventHandlers/CustomerCreatedHandler.cs | 6 +++--- .../Configurations/AddressConfiguration.cs | 2 -- .../Configurations/CustomerConfiguration.cs | 2 -- Src/WebUI/WebUI.csproj | 18 +++++++++--------- 6 files changed, 12 insertions(+), 35 deletions(-) diff --git a/Src/Application/Customers/Commands/CreateCustomer/CreateCustomerCommandValidator.cs b/Src/Application/Customers/Commands/CreateCustomer/CreateCustomerCommandValidator.cs index a36baa7..271f749 100644 --- a/Src/Application/Customers/Commands/CreateCustomer/CreateCustomerCommandValidator.cs +++ b/Src/Application/Customers/Commands/CreateCustomer/CreateCustomerCommandValidator.cs @@ -13,9 +13,6 @@ public CreateCustomerCommandValidator() RuleFor(x => x.CompanyName).MaximumLength(40).NotEmpty(); RuleFor(x => x.ContactName).MaximumLength(30); RuleFor(x => x.ContactTitle).MaximumLength(30); - //RuleFor(x => x.Country).MaximumLength(15); - //RuleFor(x => x.Fax).MaximumLength(24); - //RuleFor(x => x.Phone).MaximumLength(24); RuleFor(x => x.PostalCode).NotEmpty(); RuleFor(x => x.Region).MaximumLength(15); } diff --git a/Src/Application/Customers/Commands/UpdateCustomer/UpdateCustomerCommandValidator.cs b/Src/Application/Customers/Commands/UpdateCustomer/UpdateCustomerCommandValidator.cs index 7c10244..2d581fa 100644 --- a/Src/Application/Customers/Commands/UpdateCustomer/UpdateCustomerCommandValidator.cs +++ b/Src/Application/Customers/Commands/UpdateCustomer/UpdateCustomerCommandValidator.cs @@ -14,24 +14,8 @@ public UpdateCustomerCommandValidator() RuleFor(x => x.CompanyName).MaximumLength(40).NotEmpty(); RuleFor(x => x.ContactName).MaximumLength(30); RuleFor(x => x.ContactTitle).MaximumLength(30); - //RuleFor(x => x.Country).MaximumLength(15); RuleFor(x => x.Fax).NotEmpty(); RuleFor(x => x.Phone).NotEmpty(); - //RuleFor(x => x.PostalCode).MaximumLength(10); RuleFor(x => x.Region).MaximumLength(15); - - // RuleFor(c => c.PostalCode).Matches(@"^\d{4}$") - // .When(c => c.Country == "Australia") - // .WithMessage("Australian Postcodes have 4 digits"); - // - // RuleFor(c => c.Phone) - // .Must(HaveQueenslandLandLine) - // .When(c => c.Country == "Australia" && c.PostalCode.StartsWith("4")) - // .WithMessage("Customers in QLD require at least one QLD landline."); } - - // private static bool HaveQueenslandLandLine(UpdateCustomerCommand model, string phoneValue) - // { - // return model.Phone.StartsWith("07") || model.Fax.StartsWith("07"); - // } } \ No newline at end of file diff --git a/Src/Application/Customers/EventHandlers/CustomerCreatedHandler.cs b/Src/Application/Customers/EventHandlers/CustomerCreatedHandler.cs index b67cda5..2033c7d 100644 --- a/Src/Application/Customers/EventHandlers/CustomerCreatedHandler.cs +++ b/Src/Application/Customers/EventHandlers/CustomerCreatedHandler.cs @@ -5,11 +5,11 @@ namespace Northwind.Application.Customers.EventHandlers; // ReSharper disable once UnusedType.Global -public class CustomerCreatedHandler(INotificationService notification) : INotificationHandler +public class CustomerCreatedHandler(INotificationService notificationService) : INotificationHandler { - public async Task Handle(CustomerCreatedEvent evt, CancellationToken cancellationToken) + public async Task Handle(CustomerCreatedEvent notification, CancellationToken cancellationToken) { // Publish notification to external service so welcome email can be sent - await notification.SendAsync(new MessageDto("From", "To", "Subject - Welcome to Northwind365", "Body")); + await notificationService.SendAsync(new MessageDto("From", "To", "Subject - Welcome to Northwind365", "Body")); } } \ No newline at end of file diff --git a/Src/Infrastructure/Persistence/Configurations/AddressConfiguration.cs b/Src/Infrastructure/Persistence/Configurations/AddressConfiguration.cs index 59d49d5..4fe1da3 100644 --- a/Src/Infrastructure/Persistence/Configurations/AddressConfiguration.cs +++ b/Src/Infrastructure/Persistence/Configurations/AddressConfiguration.cs @@ -9,9 +9,7 @@ internal static void BuildAction(ComplexPropertyBuilder
addressBuilder) { addressBuilder.Property(m => m.Line1).HasMaxLength(60); addressBuilder.Property(m => m.City).HasMaxLength(50); - //addressBuilder.Property(m => m.PostalCode).HasMaxLength(10); addressBuilder.Property(m => m.Region).HasMaxLength(100); - //addressBuilder.Property(m => m.Country).HasMaxLength(100); addressBuilder.ComplexProperty(m => m.PostalCode, builder => builder.Property(m => m.Number).HasMaxLength(10)); addressBuilder.ComplexProperty(m => m.Country, builder => builder.Property(m => m.Name).HasMaxLength(100)); diff --git a/Src/Infrastructure/Persistence/Configurations/CustomerConfiguration.cs b/Src/Infrastructure/Persistence/Configurations/CustomerConfiguration.cs index 109fe1c..53c7beb 100644 --- a/Src/Infrastructure/Persistence/Configurations/CustomerConfiguration.cs +++ b/Src/Infrastructure/Persistence/Configurations/CustomerConfiguration.cs @@ -26,10 +26,8 @@ public void Configure(EntityTypeBuilder builder) builder.Property(e => e.ContactTitle).HasMaxLength(50); builder.ComplexProperty(e => e.Fax, faxBuilder => faxBuilder.Property(m => m.Number).HasMaxLength(24)); - //builder.Property(e => e.Fax).HasMaxLength(24); builder.ComplexProperty(e => e.Phone, phoneBuilder => phoneBuilder.Property(m => m.Number).HasMaxLength(24)); - //builder.Property(e => e.Phone).HasMaxLength(24); builder.HasMany(e => e.Orders) .WithOne(p => p.Customer) diff --git a/Src/WebUI/WebUI.csproj b/Src/WebUI/WebUI.csproj index 21ad102..063f6bf 100644 --- a/Src/WebUI/WebUI.csproj +++ b/Src/WebUI/WebUI.csproj @@ -77,15 +77,15 @@ <_ContentIncludedByDefault Remove="Pages\_ViewStart.cshtml" /> - - - - - - - - - + + + + + + + + +