Files
server/src/Admin/Models/UserEditModel.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
2.4 KiB
C#
Raw Normal View History

using System.ComponentModel.DataAnnotations;
using Bit.Core.Billing.Models;
using Bit.Core.Entities;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Core.Vault.Entities;
2018-03-22 15:50:56 -04:00
namespace Bit.Admin.Models;
2022-08-29 16:06:55 -04:00
public class UserEditModel
2018-03-22 15:50:56 -04:00
{
public UserEditModel()
{
}
public UserEditModel(
User user,
bool isTwoFactorEnabled,
IEnumerable<Cipher> ciphers,
BillingInfo billingInfo,
BillingHistoryInfo billingHistoryInfo,
2018-03-22 15:50:56 -04:00
GlobalSettings globalSettings)
{
User = UserViewModel.MapViewModel(user, isTwoFactorEnabled, ciphers);
2018-03-22 15:50:56 -04:00
BillingInfo = billingInfo;
BillingHistoryInfo = billingHistoryInfo;
2018-03-22 15:50:56 -04:00
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
2021-12-16 15:35:09 +01:00
2019-02-25 10:39:04 -05:00
Name = user.Name;
Email = user.Email;
2018-03-22 15:50:56 -04:00
EmailVerified = user.EmailVerified;
Premium = user.Premium;
MaxStorageGb = user.MaxStorageGb;
2018-03-22 15:50:56 -04:00
Gateway = user.Gateway;
GatewayCustomerId = user.GatewayCustomerId;
GatewaySubscriptionId = user.GatewaySubscriptionId;
LicenseKey = user.LicenseKey;
PremiumExpirationDate = user.PremiumExpirationDate;
}
2018-03-22 15:50:56 -04:00
public UserViewModel User { get; init; }
public BillingInfo BillingInfo { get; init; }
public BillingHistoryInfo BillingHistoryInfo { get; init; }
2018-03-22 15:50:56 -04:00
public string RandomLicenseKey => CoreHelpers.SecureRandomString(20);
public string OneYearExpirationDate => DateTime.Now.AddYears(1).ToString("yyyy-MM-ddTHH:mm");
public string BraintreeMerchantId { get; init; }
2018-03-22 15:50:56 -04:00
[Display(Name = "Name")]
public string Name { get; init; }
2018-03-22 15:50:56 -04:00
[Required]
[Display(Name = "Email")]
public string Email { get; init; }
2018-03-22 15:50:56 -04:00
[Display(Name = "Email Verified")]
public bool EmailVerified { get; init; }
2018-03-22 15:50:56 -04:00
[Display(Name = "Premium")]
public bool Premium { get; init; }
2018-03-22 15:50:56 -04:00
[Display(Name = "Max. Storage GB")]
public short? MaxStorageGb { get; init; }
2018-03-22 15:50:56 -04:00
[Display(Name = "Gateway")]
public Core.Enums.GatewayType? Gateway { get; init; }
2018-03-22 15:50:56 -04:00
[Display(Name = "Gateway Customer Id")]
public string GatewayCustomerId { get; init; }
2018-03-22 15:50:56 -04:00
[Display(Name = "Gateway Subscription Id")]
public string GatewaySubscriptionId { get; init; }
2018-03-22 15:50:56 -04:00
[Display(Name = "License Key")]
public string LicenseKey { get; init; }
2018-03-22 15:50:56 -04:00
[Display(Name = "Premium Expiration Date")]
public DateTime? PremiumExpirationDate { get; init; }
2018-03-22 15:50:56 -04:00
}