2018-03-23 09:29:11 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2018-03-23 09:29:11 -04:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
|
using Bit.Core.Models.Data;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.Admin.Models
|
|
|
|
|
|
{
|
|
|
|
|
|
public class OrganizationViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public OrganizationViewModel() { }
|
|
|
|
|
|
|
2020-02-25 14:28:41 -05:00
|
|
|
|
public OrganizationViewModel(Organization org, IEnumerable<OrganizationUserUserDetails> orgUsers,
|
|
|
|
|
|
IEnumerable<Cipher> ciphers, IEnumerable<Collection> collections, IEnumerable<Group> groups,
|
|
|
|
|
|
IEnumerable<Policy> policies)
|
2018-03-23 09:29:11 -04:00
|
|
|
|
{
|
|
|
|
|
|
Organization = org;
|
2021-06-07 09:08:34 -05:00
|
|
|
|
HasPublicPrivateKeys = org.PublicKey != null && org.PrivateKey != null;
|
2021-10-20 17:10:51 -04:00
|
|
|
|
UserInvitedCount = orgUsers.Count(u => u.Status == OrganizationUserStatusType.Invited);
|
|
|
|
|
|
UserAcceptedCount = orgUsers.Count(u => u.Status == OrganizationUserStatusType.Accepted);
|
|
|
|
|
|
UserConfirmedCount = orgUsers.Count(u => u.Status == OrganizationUserStatusType.Confirmed);
|
2018-03-23 09:29:11 -04:00
|
|
|
|
UserCount = orgUsers.Count();
|
2020-02-25 14:28:41 -05:00
|
|
|
|
CipherCount = ciphers.Count();
|
|
|
|
|
|
CollectionCount = collections.Count();
|
|
|
|
|
|
GroupCount = groups?.Count() ?? 0;
|
|
|
|
|
|
PolicyCount = policies?.Count() ?? 0;
|
2018-03-24 20:00:11 -04:00
|
|
|
|
Owners = string.Join(", ",
|
|
|
|
|
|
orgUsers
|
|
|
|
|
|
.Where(u => u.Type == OrganizationUserType.Owner && u.Status == OrganizationUserStatusType.Confirmed)
|
|
|
|
|
|
.Select(u => u.Email));
|
|
|
|
|
|
Admins = string.Join(", ",
|
|
|
|
|
|
orgUsers
|
|
|
|
|
|
.Where(u => u.Type == OrganizationUserType.Admin && u.Status == OrganizationUserStatusType.Confirmed)
|
|
|
|
|
|
.Select(u => u.Email));
|
2018-03-23 09:29:11 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Organization Organization { get; set; }
|
|
|
|
|
|
public string Owners { get; set; }
|
|
|
|
|
|
public string Admins { get; set; }
|
2021-10-20 17:10:51 -04:00
|
|
|
|
public int UserInvitedCount { get; set; }
|
|
|
|
|
|
public int UserConfirmedCount { get; set; }
|
|
|
|
|
|
public int UserAcceptedCount { get; set; }
|
2018-03-23 09:29:11 -04:00
|
|
|
|
public int UserCount { get; set; }
|
2020-02-25 14:28:41 -05:00
|
|
|
|
public int CipherCount { get; set; }
|
|
|
|
|
|
public int CollectionCount { get; set; }
|
|
|
|
|
|
public int GroupCount { get; set; }
|
|
|
|
|
|
public int PolicyCount { get; set; }
|
2021-06-07 09:08:34 -05:00
|
|
|
|
public bool HasPublicPrivateKeys { get; set; }
|
2018-03-23 09:29:11 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|