2022-06-29 19:46:41 -04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2019-02-25 10:39:04 -05:00
|
|
|
|
using Bit.Core.Models.Business;
|
2021-02-22 15:35:16 -06:00
|
|
|
|
using Bit.Core.Settings;
|
2018-03-22 17:33:22 -04:00
|
|
|
|
using Bit.Core.Utilities;
|
2018-03-22 15:50:56 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Admin.Models;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2018-03-22 15:50:56 -04:00
|
|
|
|
public class UserEditModel : UserViewModel
|
|
|
|
|
|
{
|
2018-03-22 17:33:22 -04:00
|
|
|
|
public UserEditModel() { }
|
|
|
|
|
|
|
2018-03-22 15:50:56 -04:00
|
|
|
|
public UserEditModel(User user, IEnumerable<Cipher> ciphers, BillingInfo billingInfo,
|
|
|
|
|
|
GlobalSettings globalSettings)
|
|
|
|
|
|
: base(user, ciphers)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2018-03-22 15:50:56 -04:00
|
|
|
|
BillingInfo = billingInfo;
|
|
|
|
|
|
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;
|
2018-03-22 17:33:22 -04:00
|
|
|
|
Premium = user.Premium;
|
|
|
|
|
|
MaxStorageGb = user.MaxStorageGb;
|
2018-03-22 15:50:56 -04:00
|
|
|
|
Gateway = user.Gateway;
|
2018-03-22 17:33:22 -04:00
|
|
|
|
GatewayCustomerId = user.GatewayCustomerId;
|
|
|
|
|
|
GatewaySubscriptionId = user.GatewaySubscriptionId;
|
|
|
|
|
|
LicenseKey = user.LicenseKey;
|
|
|
|
|
|
PremiumExpirationDate = user.PremiumExpirationDate;
|
|
|
|
|
|
}
|
2018-03-22 15:50:56 -04:00
|
|
|
|
|
|
|
|
|
|
public BillingInfo BillingInfo { get; set; }
|
|
|
|
|
|
public string RandomLicenseKey => CoreHelpers.SecureRandomString(20);
|
|
|
|
|
|
public string OneYearExpirationDate => DateTime.Now.AddYears(1).ToString("yyyy-MM-ddTHH:mm");
|
|
|
|
|
|
public string BraintreeMerchantId { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Name")]
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
[Display(Name = "Email")]
|
|
|
|
|
|
public string Email { get; set; }
|
|
|
|
|
|
[Display(Name = "Email Verified")]
|
|
|
|
|
|
public bool EmailVerified { get; set; }
|
|
|
|
|
|
[Display(Name = "Premium")]
|
|
|
|
|
|
public bool Premium { get; set; }
|
|
|
|
|
|
[Display(Name = "Max. Storage GB")]
|
|
|
|
|
|
public short? MaxStorageGb { get; set; }
|
|
|
|
|
|
[Display(Name = "Gateway")]
|
|
|
|
|
|
public Core.Enums.GatewayType? Gateway { get; set; }
|
|
|
|
|
|
[Display(Name = "Gateway Customer Id")]
|
|
|
|
|
|
public string GatewayCustomerId { get; set; }
|
|
|
|
|
|
[Display(Name = "Gateway Subscription Id")]
|
|
|
|
|
|
public string GatewaySubscriptionId { get; set; }
|
|
|
|
|
|
[Display(Name = "License Key")]
|
|
|
|
|
|
public string LicenseKey { get; set; }
|
|
|
|
|
|
[Display(Name = "Premium Expiration Date")]
|
|
|
|
|
|
public DateTime? PremiumExpirationDate { get; set; }
|
2022-08-29 15:53:48 -04:00
|
|
|
|
|
2018-03-22 15:50:56 -04:00
|
|
|
|
public User ToUser(User existingUser)
|
|
|
|
|
|
{
|
|
|
|
|
|
existingUser.Name = Name;
|
|
|
|
|
|
existingUser.Email = Email;
|
|
|
|
|
|
existingUser.EmailVerified = EmailVerified;
|
|
|
|
|
|
existingUser.Premium = Premium;
|
|
|
|
|
|
existingUser.MaxStorageGb = MaxStorageGb;
|
|
|
|
|
|
existingUser.Gateway = Gateway;
|
|
|
|
|
|
existingUser.GatewayCustomerId = GatewayCustomerId;
|
|
|
|
|
|
existingUser.GatewaySubscriptionId = GatewaySubscriptionId;
|
|
|
|
|
|
existingUser.LicenseKey = LicenseKey;
|
|
|
|
|
|
existingUser.PremiumExpirationDate = PremiumExpirationDate;
|
|
|
|
|
|
return existingUser;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|