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

125 lines
5.0 KiB
C#
Raw Normal View History

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;
using Bit.Core;
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;
using Bit.Core.Utilities;
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,
2019-02-25 10:39:04 -05:00
BillingInfo billingInfo, GlobalSettings globalSettings)
2018-03-23 09:29:11 -04:00
: base(org, orgUsers)
2018-03-22 14:29:33 -04:00
{
2019-02-25 10:39:04 -05:00
BillingInfo = billingInfo;
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;
MaxCollections = org.MaxCollections;
UseGroups = org.UseGroups;
UseDirectory = org.UseDirectory;
UseEvents = org.UseEvents;
UseTotp = org.UseTotp;
2018-04-20 16:37:17 -04:00
Use2fa = org.Use2fa;
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; }
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")]
public short? Seats { get; set; }
[Display(Name = "Max. Collections")]
public short? MaxCollections { get; set; }
[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; }
[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; }
public Organization ToOrganization(Organization existingOrganization)
{
existingOrganization.Name = Name;
existingOrganization.BusinessName = BusinessName;
existingOrganization.BillingEmail = BillingEmail;
existingOrganization.PlanType = PlanType.Value;
existingOrganization.Plan = Plan;
existingOrganization.Seats = Seats;
existingOrganization.MaxCollections = MaxCollections;
existingOrganization.UseGroups = UseGroups;
existingOrganization.UseDirectory = UseDirectory;
existingOrganization.UseEvents = UseEvents;
existingOrganization.UseTotp = UseTotp;
2018-04-20 16:37:17 -04:00
existingOrganization.Use2fa = Use2fa;
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;
return existingOrganization;
}
}
}