| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.ComponentModel.DataAnnotations; |
| | 4 | | using System.ComponentModel.DataAnnotations.Schema; |
| | 5 | | using System.Linq; |
| | 6 | | using System.Runtime.Serialization; |
| | 7 | | using System.Text.Json.Serialization; |
| | 8 | | using System.Threading.Tasks; |
| | 9 | | using Microsoft.AspNetCore.Identity; |
| | 10 | | using MUNity.Base; |
| | 11 | | using MUNity.Database.Models.User; |
| | 12 | | using MUNityCore.Models.User; |
| | 13 | |
|
| | 14 | |
|
| | 15 | | namespace MUNity.Database.Models.User |
| | 16 | | { |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// a registered user on the platform. Do not use this Model |
| | 20 | | /// inside any of the controllers unless you use it to validate something. |
| | 21 | | /// When sending out information, always use the UserSchema |
| | 22 | | /// </summary> |
| | 23 | | public class MunityUser : IdentityUser, IUserPrivacySettings |
| | 24 | | { |
| | 25 | |
|
| | 26 | | [MaxLength(100)] |
| 0 | 27 | | public string Title { get; set; } |
| | 28 | |
|
| | 29 | | [MaxLength(250)] |
| 19 | 30 | | public string Forename { get; set; } |
| | 31 | |
|
| | 32 | | [MaxLength(250)] |
| 19 | 33 | | public string Lastname { get; set; } |
| | 34 | |
|
| | 35 | | [MaxLength(250)] |
| 0 | 36 | | public string Gender { get; set; } |
| | 37 | |
|
| 6 | 38 | | public DateOnly Birthday { get; set; } // TODO: Change to DateOnly |
| | 39 | |
|
| | 40 | | [MaxLength(300)] |
| 1 | 41 | | public string Country { get; set; } |
| | 42 | |
|
| | 43 | | [MaxLength(300)] |
| 0 | 44 | | public string Street { get; set; } |
| | 45 | |
|
| | 46 | | [MaxLength(50)] |
| 1 | 47 | | public string Zipcode { get; set; } |
| | 48 | |
|
| | 49 | | [MaxLength(300)] |
| 1 | 50 | | public string City { get; set; } |
| | 51 | |
|
| | 52 | | [MaxLength(20)] |
| 1 | 53 | | public string HouseNumber { get; set; } |
| | 54 | |
|
| | 55 | | [MaxLength(250)] |
| 0 | 56 | | public string ProfileImageName { get; set; } |
| | 57 | |
|
| 0 | 58 | | public DateTime RegistrationDate { get; set; } |
| | 59 | |
|
| 0 | 60 | | public DateTime LastOnline { get; set; } |
| | 61 | |
|
| 0 | 62 | | public EUserState UserState { get; set; } |
| | 63 | |
|
| 0 | 64 | | public ICollection<Resolution.ResolutionAuth> CreatedResolutions { get; set; } |
| | 65 | |
|
| | 66 | | //public ICollection<MunityUserRole> UserRoles { get; set; } |
| | 67 | |
|
| 0 | 68 | | public ICollection<UserNotification> Notifications { get; set; } |
| | 69 | |
|
| 21 | 70 | | public ICollection<UserFriend> Friends { get; set; } = new List<UserFriend>(); |
| | 71 | |
|
| 21 | 72 | | public ICollection<UserFriend> InverseFriends { get; set; } = new List<UserFriend>(); |
| | 73 | |
|
| 21 | 74 | | public ICollection<UserBlocked> BlockedUsers { get; set; } = new List<UserBlocked>(); |
| | 75 | |
|
| 21 | 76 | | public ICollection<UserBlocked> BlockedBy { get; set; } = new List<UserBlocked>(); |
| | 77 | |
|
| 0 | 78 | | public ENameDisplayMode PublicNameDisplayMode { get; set; } |
| 0 | 79 | | public ENameDisplayMode InternalNameDisplayMode { get; set; } |
| 0 | 80 | | public ENameDisplayMode ConferenceNameDisplayMode { get; set; } |
| 0 | 81 | | public EDisplayAuthMode ConferenceHistoryDisplayMode { get; set; } |
| 0 | 82 | | public EDisplayAuthMode FriendslistDisplayMode { get; set; } |
| 0 | 83 | | public EDisplayAuthMode PinboardDisplayMode { get; set; } |
| 0 | 84 | | public EDisplayAuthMode AgeDisplayMode { get; set; } |
| | 85 | |
|
| 2 | 86 | | public bool IsShadowUser { get; set; } |
| | 87 | |
|
| | 88 | | [MaxLength(32)] |
| 2 | 89 | | public string InviteSecret { get; set; } |
| | 90 | |
|
| | 91 | | [NotMapped] |
| | 92 | | public string GetDisplayNamePublic |
| | 93 | | { |
| | 94 | | get |
| 0 | 95 | | { |
| 0 | 96 | | switch (PublicNameDisplayMode) |
| | 97 | | { |
| | 98 | | case ENameDisplayMode.FullName: |
| 0 | 99 | | return $"{Forename} {Lastname}"; |
| | 100 | | case ENameDisplayMode.FullForenameAndFirstLetterLastName: |
| 0 | 101 | | return $"{Forename} " + (Lastname.Length > 0 ? Lastname[0] + "." : ""); |
| | 102 | | case ENameDisplayMode.FirstLetterForenameFullLastName: |
| 0 | 103 | | return (Forename.Length > 0 ? Forename[0] + "." : "") + $" {Lastname}"; |
| | 104 | | case ENameDisplayMode.Initals: |
| 0 | 105 | | return (Forename.Length > 0 ? Forename[0] + "." : "") + " " + (Lastname.Length > 0 ? Lastname[0] |
| | 106 | | default: |
| 0 | 107 | | throw new NotImplementedException(); |
| | 108 | | } |
| 0 | 109 | | } |
| | 110 | | } |
| | 111 | |
|
| 6 | 112 | | public MunityUser() |
| 6 | 113 | | { |
| | 114 | | //this.Id = Guid.NewGuid().ToString(); |
| 6 | 115 | | } |
| | 116 | |
|
| 15 | 117 | | public MunityUser(string username, string email) |
| 15 | 118 | | { |
| | 119 | | //Id = Guid.NewGuid().ToString(); |
| 15 | 120 | | this.UserName = username; |
| 15 | 121 | | this.NormalizedUserName = username.ToUpper(); |
| 15 | 122 | | this.Email = email; |
| 15 | 123 | | this.NormalizedEmail = email.ToUpper(); |
| 15 | 124 | | } |
| | 125 | |
|
| | 126 | |
|
| | 127 | | } |
| | 128 | | } |