1
0
mirror of https://github.com/bitwarden/server synced 2025-12-13 14:53:34 +00:00
Files
server/src/Api/AdminConsole/Models/Request/Providers/ProviderUpdateRequestModel.cs
2025-07-08 17:32:49 -04:00

38 lines
1.3 KiB
C#

// FIXME: Update this file to be null safe and then delete the line below
#nullable disable
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using Bit.Core.AdminConsole.Entities.Provider;
using Bit.Core.Settings;
using Bit.Core.Utilities;
namespace Bit.Api.AdminConsole.Models.Request.Providers;
public class ProviderUpdateRequestModel
{
[Required]
[StringLength(50, ErrorMessage = "The field Name exceeds the maximum length.")]
[JsonConverter(typeof(HtmlEncodingStringConverter))]
public string Name { get; set; }
[StringLength(50, ErrorMessage = "The field Business Name exceeds the maximum length.")]
[JsonConverter(typeof(HtmlEncodingStringConverter))]
public string BusinessName { get; set; }
[EmailAddress]
[Required]
[StringLength(256)]
public string BillingEmail { get; set; }
public virtual Provider ToProvider(Provider existingProvider, GlobalSettings globalSettings)
{
if (!globalSettings.SelfHosted)
{
// These items come from the license file
existingProvider.Name = Name;
existingProvider.BusinessName = BusinessName;
existingProvider.BillingEmail = BillingEmail?.ToLowerInvariant()?.Trim();
}
return existingProvider;
}
}