using System; using System.Collections.Generic; using System.Linq; using Bit.Core.Enums; using Bit.Core.Models.Table; namespace Bit.Portal.Models { public class PoliciesModel { public PoliciesModel(ICollection policies, bool useSso) { if (policies == null) { return; } var policyDict = policies?.ToDictionary(p => p.Type); Policies = new List(); foreach (var type in Enum.GetValues(typeof(PolicyType)).Cast()) { if (type == PolicyType.RequireSso && !useSso) { continue; } var enabled = policyDict.ContainsKey(type) ? policyDict[type].Enabled : false; Policies.Add(new PolicyModel(type, enabled)); } } public List Policies { get; set; } } }