-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ac/pm-13790/remove-h1-implement-new-mini-det…
…ails-organization-user-endpoint-feature-flag
- Loading branch information
Showing
16 changed files
with
719 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Bit.Core.AdminConsole.Entities.Provider; | ||
using Bit.Core.AdminConsole.Enums.Provider; | ||
using Bit.SharedWeb.Utilities; | ||
|
||
namespace Bit.Admin.AdminConsole.Models; | ||
|
||
public class CreateMspProviderModel : IValidatableObject | ||
{ | ||
[Display(Name = "Owner Email")] | ||
public string OwnerEmail { get; set; } | ||
|
||
[Display(Name = "Teams (Monthly) Seat Minimum")] | ||
public int TeamsMonthlySeatMinimum { get; set; } | ||
|
||
[Display(Name = "Enterprise (Monthly) Seat Minimum")] | ||
public int EnterpriseMonthlySeatMinimum { get; set; } | ||
|
||
public virtual Provider ToProvider() | ||
{ | ||
return new Provider | ||
{ | ||
Type = ProviderType.Msp | ||
}; | ||
} | ||
|
||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) | ||
{ | ||
if (string.IsNullOrWhiteSpace(OwnerEmail)) | ||
{ | ||
var ownerEmailDisplayName = nameof(OwnerEmail).GetDisplayAttribute<CreateMspProviderModel>()?.GetName() ?? nameof(OwnerEmail); | ||
yield return new ValidationResult($"The {ownerEmailDisplayName} field is required."); | ||
} | ||
if (TeamsMonthlySeatMinimum < 0) | ||
{ | ||
var teamsMinimumSeatsDisplayName = nameof(TeamsMonthlySeatMinimum).GetDisplayAttribute<CreateMspProviderModel>()?.GetName() ?? nameof(TeamsMonthlySeatMinimum); | ||
yield return new ValidationResult($"The {teamsMinimumSeatsDisplayName} field can not be negative."); | ||
} | ||
if (EnterpriseMonthlySeatMinimum < 0) | ||
{ | ||
var enterpriseMinimumSeatsDisplayName = nameof(EnterpriseMonthlySeatMinimum).GetDisplayAttribute<CreateMspProviderModel>()?.GetName() ?? nameof(EnterpriseMonthlySeatMinimum); | ||
yield return new ValidationResult($"The {enterpriseMinimumSeatsDisplayName} field can not be negative."); | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/Admin/AdminConsole/Models/CreateMultiOrganizationEnterpriseProviderModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Bit.Core.AdminConsole.Entities.Provider; | ||
using Bit.Core.AdminConsole.Enums.Provider; | ||
using Bit.Core.Billing.Enums; | ||
using Bit.SharedWeb.Utilities; | ||
|
||
namespace Bit.Admin.AdminConsole.Models; | ||
|
||
public class CreateMultiOrganizationEnterpriseProviderModel : IValidatableObject | ||
{ | ||
[Display(Name = "Owner Email")] | ||
public string OwnerEmail { get; set; } | ||
|
||
[Display(Name = "Enterprise Seat Minimum")] | ||
public int EnterpriseSeatMinimum { get; set; } | ||
|
||
[Display(Name = "Plan")] | ||
[Required] | ||
public PlanType? Plan { get; set; } | ||
|
||
public virtual Provider ToProvider() | ||
{ | ||
return new Provider | ||
{ | ||
Type = ProviderType.MultiOrganizationEnterprise | ||
}; | ||
} | ||
|
||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) | ||
{ | ||
if (string.IsNullOrWhiteSpace(OwnerEmail)) | ||
{ | ||
var ownerEmailDisplayName = nameof(OwnerEmail).GetDisplayAttribute<CreateMultiOrganizationEnterpriseProviderModel>()?.GetName() ?? nameof(OwnerEmail); | ||
yield return new ValidationResult($"The {ownerEmailDisplayName} field is required."); | ||
} | ||
if (EnterpriseSeatMinimum < 0) | ||
{ | ||
var enterpriseSeatMinimumDisplayName = nameof(EnterpriseSeatMinimum).GetDisplayAttribute<CreateMultiOrganizationEnterpriseProviderModel>()?.GetName() ?? nameof(EnterpriseSeatMinimum); | ||
yield return new ValidationResult($"The {enterpriseSeatMinimumDisplayName} field can not be negative."); | ||
} | ||
if (Plan != PlanType.EnterpriseAnnually && Plan != PlanType.EnterpriseMonthly) | ||
{ | ||
var planDisplayName = nameof(Plan).GetDisplayAttribute<CreateMultiOrganizationEnterpriseProviderModel>()?.GetName() ?? nameof(Plan); | ||
yield return new ValidationResult($"The {planDisplayName} field must be set to Enterprise Annually or Enterprise Monthly."); | ||
} | ||
} | ||
} |
Oops, something went wrong.