diff --git a/src/Admin/Models/CreateProviderModel.cs b/src/Admin/Models/CreateProviderModel.cs index a9a2f4ac4391..9dcd218fa625 100644 --- a/src/Admin/Models/CreateProviderModel.cs +++ b/src/Admin/Models/CreateProviderModel.cs @@ -15,6 +15,9 @@ public CreateProviderModel() { } [Display(Name = "Owner Email")] public string OwnerEmail { get; set; } + [Display(Name = "Name")] + public string Name { get; set; } + [Display(Name = "Business Name")] public string BusinessName { get; set; } @@ -26,6 +29,7 @@ public virtual Provider ToProvider() return new Provider() { Type = Type, + Name = Name, BusinessName = BusinessName, BillingEmail = BillingEmail?.ToLowerInvariant().Trim() }; @@ -38,19 +42,24 @@ public IEnumerable Validate(ValidationContext validationContex case ProviderType.Msp: if (string.IsNullOrWhiteSpace(OwnerEmail)) { - var ownerEmailDisplayName = nameof(OwnerEmail).GetDisplayAttribute()?.GetName(); + var ownerEmailDisplayName = nameof(OwnerEmail).GetDisplayAttribute()?.GetName() ?? nameof(OwnerEmail); yield return new ValidationResult($"The {ownerEmailDisplayName} field is required."); } break; case ProviderType.Reseller: + if (string.IsNullOrWhiteSpace(Name)) + { + var nameDisplayName = nameof(Name).GetDisplayAttribute()?.GetName() ?? nameof(Name); + yield return new ValidationResult($"The {nameDisplayName} field is required."); + } if (string.IsNullOrWhiteSpace(BusinessName)) { - var businessNameDisplayName = nameof(BusinessName).GetDisplayAttribute()?.GetName(); + var businessNameDisplayName = nameof(BusinessName).GetDisplayAttribute()?.GetName() ?? nameof(BusinessName); yield return new ValidationResult($"The {businessNameDisplayName} field is required."); } if (string.IsNullOrWhiteSpace(BillingEmail)) { - var billingEmailDisplayName = nameof(BillingEmail).GetDisplayAttribute()?.GetName(); + var billingEmailDisplayName = nameof(BillingEmail).GetDisplayAttribute()?.GetName() ?? nameof(BillingEmail); yield return new ValidationResult($"The {billingEmailDisplayName} field is required."); } break; diff --git a/src/Admin/Views/Providers/Create.cshtml b/src/Admin/Views/Providers/Create.cshtml index 2263da06e1c9..107e93150b41 100644 --- a/src/Admin/Views/Providers/Create.cshtml +++ b/src/Admin/Views/Providers/Create.cshtml @@ -17,7 +17,7 @@
- +
@foreach(ProviderType providerType in Enum.GetValues(typeof(ProviderType))) @@ -31,7 +31,7 @@
} - +

MSP Info

@@ -39,9 +39,13 @@
- +

Reseller Info

+
+ + +
@@ -51,6 +55,6 @@
- +
diff --git a/util/Migrator/DbScripts_data_migration/2023-08-03_00_PopulateResellerNames.sql b/util/Migrator/DbScripts_data_migration/2023-08-03_00_PopulateResellerNames.sql new file mode 100644 index 000000000000..b5eb0b9aa3e5 --- /dev/null +++ b/util/Migrator/DbScripts_data_migration/2023-08-03_00_PopulateResellerNames.sql @@ -0,0 +1,5 @@ +-- Reseller Providers were being created with a NULL value in the [Name] column. +-- This script will populate them with the value from [BusinessName] which was already required. +UPDATE [dbo].[Provider] +SET [Name] = [BusinessName] +WHERE [Name] IS NULL