2018-03-22 14:29:33 -04:00
|
|
|
|
using System;
|
2018-03-22 21:10:10 -04:00
|
|
|
|
using System.Collections.Generic;
|
2018-03-22 14:29:33 -04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2018-03-22 21:10:10 -04:00
|
|
|
|
using Bit.Core.Enums;
|
2019-02-25 10:39:04 -05:00
|
|
|
|
using Bit.Core.Models.Business;
|
2018-03-22 21:10:10 -04:00
|
|
|
|
using Bit.Core.Models.Data;
|
2018-03-22 14:29:33 -04:00
|
|
|
|
using Bit.Core.Models.Table;
|
2018-03-22 17:33:22 -04:00
|
|
|
|
using Bit.Core.Utilities;
|
2021-02-22 15:35:16 -06:00
|
|
|
|
using Bit.Core.Settings;
|
2018-03-22 14:29:33 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Admin.Models
|
|
|
|
|
|
{
|
2018-03-23 09:29:11 -04:00
|
|
|
|
public class OrganizationEditModel : OrganizationViewModel
|
2018-03-22 14:29:33 -04:00
|
|
|
|
{
|
|
|
|
|
|
public OrganizationEditModel() { }
|
|
|
|
|
|
|
2018-03-22 21:10:10 -04:00
|
|
|
|
public OrganizationEditModel(Organization org, IEnumerable<OrganizationUserUserDetails> orgUsers,
|
2020-02-25 14:28:41 -05:00
|
|
|
|
IEnumerable<Cipher> ciphers, IEnumerable<Collection> collections, IEnumerable<Group> groups,
|
|
|
|
|
|
IEnumerable<Policy> policies, BillingInfo billingInfo, GlobalSettings globalSettings)
|
|
|
|
|
|
: base(org, orgUsers, ciphers, collections, groups, policies)
|
2018-03-22 14:29:33 -04:00
|
|
|
|
{
|
2019-02-25 10:39:04 -05:00
|
|
|
|
BillingInfo = billingInfo;
|
2018-03-22 17:33:22 -04:00
|
|
|
|
BraintreeMerchantId = globalSettings.Braintree.MerchantId;
|
|
|
|
|
|
|
2018-03-22 14:29:33 -04:00
|
|
|
|
Name = org.Name;
|
|
|
|
|
|
BusinessName = org.BusinessName;
|
|
|
|
|
|
BillingEmail = org.BillingEmail;
|
|
|
|
|
|
PlanType = org.PlanType;
|
|
|
|
|
|
Plan = org.Plan;
|
|
|
|
|
|
Seats = org.Seats;
|
2021-09-23 06:36:08 -04:00
|
|
|
|
MaxAutoscaleSeats = org.MaxAutoscaleSeats;
|
2018-03-22 14:29:33 -04:00
|
|
|
|
MaxCollections = org.MaxCollections;
|
2020-01-15 15:00:54 -05:00
|
|
|
|
UsePolicies = org.UsePolicies;
|
2020-07-22 09:38:39 -04:00
|
|
|
|
UseSso = org.UseSso;
|
2018-03-22 14:29:33 -04:00
|
|
|
|
UseGroups = org.UseGroups;
|
|
|
|
|
|
UseDirectory = org.UseDirectory;
|
|
|
|
|
|
UseEvents = org.UseEvents;
|
|
|
|
|
|
UseTotp = org.UseTotp;
|
2018-04-20 16:37:17 -04:00
|
|
|
|
Use2fa = org.Use2fa;
|
2019-03-02 15:09:33 -05:00
|
|
|
|
UseApi = org.UseApi;
|
2021-06-07 09:08:34 -05:00
|
|
|
|
UseResetPassword = org.UseResetPassword;
|
2018-03-22 14:29:33 -04:00
|
|
|
|
SelfHost = org.SelfHost;
|
|
|
|
|
|
UsersGetPremium = org.UsersGetPremium;
|
|
|
|
|
|
MaxStorageGb = org.MaxStorageGb;
|
|
|
|
|
|
Gateway = org.Gateway;
|
|
|
|
|
|
GatewayCustomerId = org.GatewayCustomerId;
|
|
|
|
|
|
GatewaySubscriptionId = org.GatewaySubscriptionId;
|
|
|
|
|
|
Enabled = org.Enabled;
|
|
|
|
|
|
LicenseKey = org.LicenseKey;
|
|
|
|
|
|
ExpirationDate = org.ExpirationDate;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-25 10:39:04 -05:00
|
|
|
|
public BillingInfo BillingInfo { get; set; }
|
2018-03-22 17:33:22 -04:00
|
|
|
|
public string RandomLicenseKey => CoreHelpers.SecureRandomString(20);
|
|
|
|
|
|
public string FourteenDayExpirationDate => DateTime.Now.AddDays(14).ToString("yyyy-MM-ddTHH:mm");
|
|
|
|
|
|
public string BraintreeMerchantId { get; set; }
|
2018-03-22 14:29:33 -04:00
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
[Display(Name = "Name")]
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
[Display(Name = "Business Name")]
|
|
|
|
|
|
public string BusinessName { get; set; }
|
|
|
|
|
|
[Display(Name = "Billing Email")]
|
|
|
|
|
|
public string BillingEmail { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
[Display(Name = "Plan")]
|
2018-03-22 21:10:10 -04:00
|
|
|
|
public PlanType? PlanType { get; set; }
|
2018-03-22 14:29:33 -04:00
|
|
|
|
[Required]
|
|
|
|
|
|
[Display(Name = "Plan Name")]
|
|
|
|
|
|
public string Plan { get; set; }
|
|
|
|
|
|
[Display(Name = "Seats")]
|
2021-05-17 09:43:02 -05:00
|
|
|
|
public int? Seats { get; set; }
|
2021-09-23 06:36:08 -04:00
|
|
|
|
[Display(Name = "Max. Autoscale Seats")]
|
|
|
|
|
|
public int? MaxAutoscaleSeats { get; set; }
|
2018-03-22 14:29:33 -04:00
|
|
|
|
[Display(Name = "Max. Collections")]
|
|
|
|
|
|
public short? MaxCollections { get; set; }
|
2020-01-15 15:00:54 -05:00
|
|
|
|
[Display(Name = "Policies")]
|
|
|
|
|
|
public bool UsePolicies { get; set; }
|
2020-07-22 09:38:39 -04:00
|
|
|
|
[Display(Name = "SSO")]
|
|
|
|
|
|
public bool UseSso { get; set; }
|
2018-03-22 14:29:33 -04:00
|
|
|
|
[Display(Name = "Groups")]
|
|
|
|
|
|
public bool UseGroups { get; set; }
|
|
|
|
|
|
[Display(Name = "Directory")]
|
|
|
|
|
|
public bool UseDirectory { get; set; }
|
|
|
|
|
|
[Display(Name = "Events")]
|
|
|
|
|
|
public bool UseEvents { get; set; }
|
|
|
|
|
|
[Display(Name = "TOTP")]
|
|
|
|
|
|
public bool UseTotp { get; set; }
|
2018-04-20 16:37:17 -04:00
|
|
|
|
[Display(Name = "2FA")]
|
2018-04-20 16:45:41 -04:00
|
|
|
|
public bool Use2fa { get; set; }
|
2019-03-02 15:09:33 -05:00
|
|
|
|
[Display(Name = "API")]
|
|
|
|
|
|
public bool UseApi{ get; set; }
|
2021-06-07 09:08:34 -05:00
|
|
|
|
[Display(Name = "Reset Password")]
|
|
|
|
|
|
public bool UseResetPassword { get; set; }
|
2018-04-20 16:45:41 -04:00
|
|
|
|
[Display(Name = "Self Host")]
|
2018-03-22 14:29:33 -04:00
|
|
|
|
public bool SelfHost { get; set; }
|
|
|
|
|
|
[Display(Name = "Users Get Premium")]
|
|
|
|
|
|
public bool UsersGetPremium { get; set; }
|
|
|
|
|
|
[Display(Name = "Max. Storage GB")]
|
|
|
|
|
|
public short? MaxStorageGb { get; set; }
|
|
|
|
|
|
[Display(Name = "Gateway")]
|
2018-03-22 21:10:10 -04:00
|
|
|
|
public GatewayType? Gateway { get; set; }
|
2018-03-22 14:29:33 -04:00
|
|
|
|
[Display(Name = "Gateway Customer Id")]
|
|
|
|
|
|
public string GatewayCustomerId { get; set; }
|
|
|
|
|
|
[Display(Name = "Gateway Subscription Id")]
|
|
|
|
|
|
public string GatewaySubscriptionId { get; set; }
|
|
|
|
|
|
[Display(Name = "Enabled")]
|
|
|
|
|
|
public bool Enabled { get; set; }
|
|
|
|
|
|
[Display(Name = "License Key")]
|
|
|
|
|
|
public string LicenseKey { get; set; }
|
|
|
|
|
|
[Display(Name = "Expiration Date")]
|
|
|
|
|
|
public DateTime? ExpirationDate { get; set; }
|
2021-08-11 12:44:30 -04:00
|
|
|
|
public bool SalesAssistedTrialStarted { get; set; }
|
2018-03-22 14:29:33 -04:00
|
|
|
|
|
|
|
|
|
|
public Organization ToOrganization(Organization existingOrganization)
|
|
|
|
|
|
{
|
|
|
|
|
|
existingOrganization.Name = Name;
|
|
|
|
|
|
existingOrganization.BusinessName = BusinessName;
|
2019-06-12 22:08:53 -04:00
|
|
|
|
existingOrganization.BillingEmail = BillingEmail?.ToLowerInvariant()?.Trim();
|
2018-03-22 14:29:33 -04:00
|
|
|
|
existingOrganization.PlanType = PlanType.Value;
|
|
|
|
|
|
existingOrganization.Plan = Plan;
|
|
|
|
|
|
existingOrganization.Seats = Seats;
|
|
|
|
|
|
existingOrganization.MaxCollections = MaxCollections;
|
2020-01-15 15:00:54 -05:00
|
|
|
|
existingOrganization.UsePolicies = UsePolicies;
|
2020-07-22 09:38:39 -04:00
|
|
|
|
existingOrganization.UseSso = UseSso;
|
2018-03-22 14:29:33 -04:00
|
|
|
|
existingOrganization.UseGroups = UseGroups;
|
|
|
|
|
|
existingOrganization.UseDirectory = UseDirectory;
|
|
|
|
|
|
existingOrganization.UseEvents = UseEvents;
|
|
|
|
|
|
existingOrganization.UseTotp = UseTotp;
|
2018-04-20 16:37:17 -04:00
|
|
|
|
existingOrganization.Use2fa = Use2fa;
|
2019-03-02 15:09:33 -05:00
|
|
|
|
existingOrganization.UseApi = UseApi;
|
2021-06-07 09:08:34 -05:00
|
|
|
|
existingOrganization.UseResetPassword = UseResetPassword;
|
2018-03-22 14:29:33 -04:00
|
|
|
|
existingOrganization.SelfHost = SelfHost;
|
|
|
|
|
|
existingOrganization.UsersGetPremium = UsersGetPremium;
|
|
|
|
|
|
existingOrganization.MaxStorageGb = MaxStorageGb;
|
|
|
|
|
|
existingOrganization.Gateway = Gateway;
|
|
|
|
|
|
existingOrganization.GatewayCustomerId = GatewayCustomerId;
|
|
|
|
|
|
existingOrganization.GatewaySubscriptionId = GatewaySubscriptionId;
|
|
|
|
|
|
existingOrganization.Enabled = Enabled;
|
|
|
|
|
|
existingOrganization.LicenseKey = LicenseKey;
|
|
|
|
|
|
existingOrganization.ExpirationDate = ExpirationDate;
|
2021-09-23 06:36:08 -04:00
|
|
|
|
existingOrganization.MaxAutoscaleSeats = MaxAutoscaleSeats;
|
2018-03-22 14:29:33 -04:00
|
|
|
|
return existingOrganization;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|