using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Mvc; namespace gehGassi.Web.Models { public class ApplicationUserVm { /// /// Id /// [Required(ErrorMessage = "Err_Required")] [Display(Name = "ApplicationUser_Id")] public string Id { get; set; } /// /// Benutzername überschrieben, damit hier eine E-Mail Adresse erzwungen werden kann /// [Required(ErrorMessage = "Err_Required")] [MaxLength(256, ErrorMessage = "Err_StringLength_Max")] [Remote("IsUsernameAvailable", "User", AdditionalFields = "Id", ErrorMessage = "Err_Username_InUse", HttpMethod = "POST")] [EmailAddress(ErrorMessage = "Err_InvalidEmail")] [Display(Name = "ApplicationUser_UserName")] public string UserName { get; set; } /// /// Vorname /// [Required(ErrorMessage = "Err_Required")] [MaxLength(150, ErrorMessage = "Err_StringLength_Max")] [Display(Name = "ApplicationUser_FirstName")] public string FirstName { get; set; } /// /// Nachname /// [Required(ErrorMessage = "Err_Required")] [MaxLength(150, ErrorMessage = "Err_StringLength_Max")] [Display(Name = "ApplicationUser_LastName")] public string LastName { get; set; } /// /// Id der Timzone (Zeitzone) in welcher der Benutzer sich befindet /// [MaxLength(50, ErrorMessage = "Err_StringLength_Max")] [Display(Name = "ApplicationUser_TimeZoneId")] public string TimeZoneId { get; set; } /// /// Bevorzugte Sprache (ISO2) /// [MaxLength(50, ErrorMessage = "Err_StringLength_Max")] [Display(Name = "ApplicationUser_PreferredLangauge")] public string PreferredLanguage { get; set; } /// /// Zugewiesene Rolle /// [Required(ErrorMessage = "Err_Required")] [Display(Name = "ApplicationUser_Roles")] public List Roles { get; set; } /// /// Optional - Foto des Benutzers /// [MaxLength(255, ErrorMessage = "Err_StringLength_Max")] [Display(Name = "ApplicationUser_Photo")] public string Photo { get; set; } /// /// Datum der Registrierung /// [Required(ErrorMessage = "Err_Required")] [Display(Name = "ApplicationUser_RegistrationDate")] public DateTimeOffset RegistrationDate { get; set; } /// /// Datum der letzten Anmeldung /// [Display(Name = "ApplicationUser_LastLoginDate")] public DateTimeOffset? LastLoginDate { get; set; } /// /// Vordefinierte Permissions als packed string. /// [MaxLength(500, ErrorMessage = "Err_StringLength_Max")] [Display(Name = "ApplicationUser_Permissions")] public string Permissions { get; set; } /// /// Id des zugeordneten Kunden. /// [Display(Name = "ApplicationUser_CustomerId", Description = "ApplicationUser_CustomerId_Desc")] public long? CustomerId { get; set; } /// /// Name des Kunden /// [Display(Name = "ApplicationUser_CustomerId", Description = "ApplicationUser_CustomerId_Desc")] public string CustomerName { get; set; } /// /// Id des App-Users /// null, wenn keiner zugeordnet /// [Display(Name = "ApplicationUser_AppUserId", Description = "ApplicationUser_AppUserId_Desc")] public string AppUserId { get; set; } /// /// Name des App-Users /// [Display(Name = "ApplicationUser_AppUserId", Description = "ApplicationUser_AppUserId_Desc")] public string AppUserName { get; set; } /// /// Liste der Rechte /// public List PermissionVms { get; set; } /// /// Erstellt eine Instanz /// public ApplicationUserVm() { PermissionVms = new List(); } } /// /// Erweitert das ApplicationUserVm um PAsswörter für das Anlegen eines Benutzers /// public class ApplicationUserCreateVm : ApplicationUserVm { [Required(ErrorMessage = "Err_Required")] [MaxLength(100, ErrorMessage = "Err_StringLength_Max")] [DataType(DataType.Password)] [Display(Name = "Common_Password")] public string Password { get; set; } [DataType(DataType.Password)] [Compare("Password", ErrorMessage = "Err_Compare")] [Display(Name = "Common_ConfirmPassword")] public string ConfirmPassword { get; set; } public ApplicationUserCreateVm() : base() { } } /// /// Viewmodel für die Listen-Darstellung /// public class ApplicationUserListVm { /// /// Id /// [Display(Name = "ApplicationUser_Id")] public string Id { get; set; } /// /// Benutzername überschrieben, damit hier eine E-Mail Adresse erzwungen werden kann /// [Display(Name = "ApplicationUser_UserName")] public string UserName { get; set; } /// /// Vorname /// [Display(Name = "ApplicationUser_FirstName")] public string FirstName { get; set; } /// /// Nachname /// [Display(Name = "ApplicationUser_LastName")] public string LastName { get; set; } /// /// Gibt an ob ein Benutzer gesperrt ist oder nicht /// [Display(Name = "ApplicationUser_Locked")] public bool Locked { get; set; } /// /// Zugewiesene Rolle /// [Display(Name = "ApplicationUser_Roles")] public string Roles { get; set; } /// /// Optional - Foto des Benutzers /// [Display(Name = "ApplicationUser_Photo")] public string Photo { get; set; } /// /// Datum der Registrierung /// [Display(Name = "ApplicationUser_RegistrationDate")] public DateTimeOffset RegistrationDate { get; set; } /// /// Datum der letzten Anmeldung /// [Display(Name = "ApplicationUser_LastLoginDate")] public DateTimeOffset? LastLoginDate { get; set; } /// /// Id des zugeordneten Kunden. /// [Display(Name = "ApplicationUser_CustomerId", Description = "ApplicationUser_CustomerId_Desc")] public long? CustomerId { get; set; } /// /// Name des Kunden /// [Display(Name = "ApplicationUser_CustomerId", Description = "ApplicationUser_CustomerId_Desc")] public string CustomerName { get; set; } /// /// Id des App-Users /// null, wenn keiner zugeordnet /// [Display(Name = "ApplicationUser_AppUserId", Description = "ApplicationUser_AppUserId_Desc")] public string AppUserId { get; set; } /// /// Name des App-Users /// [Display(Name = "ApplicationUser_AppUserId", Description = "ApplicationUser_AppUserId_Desc")] public string AppUserName { get; set; } /// /// 2-Faktor Authentifizierung aktiviert? /// [Display(Name = "ApplicationUser_TwoFactorEnabled")] public bool TwoFactorEnabled { get; set; } /// /// Email-Adresse bestätigt? /// [Display(Name = "ApplicationUser_EmailConfirmed")] public bool EmailConfirmed { get; set; } /// /// Gibt an ob der Benutzer online ist /// public bool IsOnline { get; set; } public ApplicationUserListVm() { } } /// /// Model für das Client-Side Update der BenutzerInfos /// public class ApplicationUserInfoVm { /// /// Benutzername überschrieben, damit hier eine E-Mail Adresse erzwungen werden kann /// [Display(Name = "ApplicationUser_UserName")] public string UserName { get; set; } /// /// Vorname /// [Display(Name = "ApplicationUser_FirstName")] public string FirstName { get; set; } /// /// Nachname /// [Display(Name = "ApplicationUser_LastName")] public string LastName { get; set; } /// /// Optional - Foto des Benutzers /// [Display(Name = "ApplicationUser_Photo")] public string Photo { get; set; } /// /// Name für die Darstellung /// public string NameForLookup { get; set; } } }