162 lines
5.2 KiB
C#
162 lines
5.2 KiB
C#
using Aperio_Control_Centre.ACSDatabase.Types;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using Aperio_Control_Centre.Aadp;
|
|
|
|
namespace Aperio_Control_Centre.ACSDatabase.Models
|
|
{
|
|
[Obsolete("Old user groups")]
|
|
public class Group
|
|
{
|
|
[Key]
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(50)]
|
|
[Display(Name = "Group name")]
|
|
[Remote(action: "VerifyName", controller: "Groups", AdditionalFields = "Id")]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
[DataType(DataType.MultilineText)]
|
|
[Display(Name = "Group information")]
|
|
[MaxLength(500)]
|
|
public string? Info { get; set; }
|
|
|
|
[Required]
|
|
public ActiveStates Active { get; set; }
|
|
|
|
[Required]
|
|
[Display(Name = "Last changed")]
|
|
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy HH:mm:ss}", ApplyFormatInEditMode = true)]
|
|
public DateTime LastChanged { get; set; }
|
|
|
|
[Required]
|
|
[Display(Name = "Timezone")]
|
|
public Timezone Timezone { get; set; }
|
|
|
|
[Required]
|
|
[Display(Name = "Timezone")]
|
|
public int TimezoneId { get; set; }
|
|
|
|
public ICollection<DeviceGroupJoin>? DeviceGroupJoins { get; set; }
|
|
|
|
public ICollection<User>? Users { get; set; }
|
|
|
|
|
|
|
|
//[NotMapped]
|
|
//[Display(Name = "Last changed")]
|
|
//[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy HH:mm:ss}", ApplyFormatInEditMode = true)]
|
|
//public DateTimeOffset LastChangedLocal => LastChanged.ToLocalTime();
|
|
|
|
//[NotMapped]
|
|
//[Display(Name = "Device selection")]
|
|
//public List<SelectListItem>? DeviceSelectList { get; set; }
|
|
|
|
//[NotMapped]
|
|
//[Display(Name = "Timezone selection")]
|
|
//public SelectList? TimezoneSelection { get; set; }
|
|
|
|
|
|
//----------- Users ------------------
|
|
//[NotMapped]
|
|
//[Display(Name = "Active cards")]
|
|
//public int UserActiveCount
|
|
//{
|
|
// get
|
|
// {
|
|
// if (Users == null)
|
|
// return 0;
|
|
|
|
// return Users.Where(u => u.Active == ActiveStates.Active).Count();
|
|
// }
|
|
//}
|
|
|
|
//[NotMapped]
|
|
//[Display(Name = "Inactive cards")]
|
|
//public int UserInactiveCount
|
|
//{
|
|
// get
|
|
// {
|
|
// if (Users == null)
|
|
// return 0;
|
|
|
|
// return Users.Where(u => u.Active == ActiveStates.Inactive).Count();
|
|
// }
|
|
//}
|
|
|
|
//[NotMapped]
|
|
//[Display(Name = "All cards")]
|
|
//public IEnumerable<User>? AllUsers
|
|
//{
|
|
// get
|
|
// {
|
|
// if (Users == null)
|
|
// return [];
|
|
|
|
// return Users.Where(u => u.Active != ActiveStates.Deleted);
|
|
// }
|
|
//}
|
|
|
|
//---------------- Devices --------------
|
|
//[NotMapped]
|
|
//[Display(Name = "Active devices")]
|
|
//public int DevicesActiveCount
|
|
//{
|
|
// get
|
|
// {
|
|
// if (DeviceGroupJoins == null)
|
|
// return 0;
|
|
|
|
// return DeviceGroupJoins
|
|
// .Where(d => d.Device?.Active == ActiveStates.Active)
|
|
// .Where(d => d.Device?.ProductClass == Enumerations.ProductClass.H1502R11 || d.Device?.ProductClass == Enumerations.ProductClass.LOCK || d.Device?.ProductClass == Enumerations.ProductClass.OPTA_V1)
|
|
// .Select(s => s.Device)
|
|
// .Count();
|
|
// }
|
|
//}
|
|
|
|
//[NotMapped]
|
|
//[Display(Name = "Inactive devices")]
|
|
//public int DevicesInActiveCount
|
|
//{
|
|
// get
|
|
// {
|
|
// if (DeviceGroupJoins == null)
|
|
// return 0;
|
|
|
|
// return DeviceGroupJoins
|
|
// .Where(d => d.Device?.Active == ActiveStates.Inactive)
|
|
// .Where(d => d.Device?.ProductClass == Enumerations.ProductClass.H1502R11 || d.Device?.ProductClass == Enumerations.ProductClass.LOCK || d.Device?.ProductClass == Enumerations.ProductClass.OPTA_V1)
|
|
// .Select(s => s.Device)
|
|
// .Count();
|
|
// }
|
|
//}
|
|
|
|
//[NotMapped]
|
|
//[Display(Name = "All devices")]
|
|
//public List<Device?> AllDevices
|
|
//{
|
|
// get
|
|
// {
|
|
// if (DeviceGroupJoins == null)
|
|
// return [];
|
|
|
|
// return DeviceGroupJoins
|
|
// .Where(d => d.Device?.Active != ActiveStates.Deleted)
|
|
// .Where(d => d.Device?.ProductClass == Enumerations.ProductClass.H1502R11 || d.Device?.ProductClass == Enumerations.ProductClass.LOCK || d.Device?.ProductClass == Enumerations.ProductClass.OPTA_V1)
|
|
// .Select(s => s.Device)
|
|
// .ToList();
|
|
// }
|
|
//}
|
|
|
|
// ------------- total ----------------------
|
|
//public int TotalUsedCount()
|
|
//{
|
|
// return (UserActiveCount + UserInactiveCount + DevicesActiveCount + DevicesInActiveCount);
|
|
//}
|
|
}
|
|
}
|