| | | 1 | | using System.ComponentModel.DataAnnotations; |
| | | 2 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 3 | | using System; |
| | | 4 | | using CrmVtbc.Integration; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | |
| | | 7 | | namespace WinSolutions.Sveta.Server.Data.DataModel.Entities |
| | | 8 | | { |
| | | 9 | | [CrmCollection("Contact")] |
| | | 10 | | public class User : ExternalRecord, ITrackableRecord |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Логин |
| | | 14 | | /// </summary> |
| | 0 | 15 | | public string Login { get; set; } |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// Имя |
| | | 19 | | /// </summary> |
| | | 20 | | [Required] |
| | | 21 | | [CrmMap("GivenName"), CrmOnlyLoad] |
| | 0 | 22 | | public string FirstName { get; set; } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Отчество |
| | | 26 | | /// </summary> |
| | | 27 | | [CrmMap, CrmOnlyLoad] |
| | 0 | 28 | | public string MiddleName { get; set; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Фамилия |
| | | 32 | | /// </summary> |
| | | 33 | | [Required] |
| | | 34 | | [CrmMap("Surname"), CrmOnlyLoad] |
| | 0 | 35 | | public string LastName { get; set; } |
| | | 36 | | |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Должность |
| | | 40 | | /// </summary> |
| | | 41 | | [CrmMap("JobTitle"), CrmOnlyLoad] |
| | 0 | 42 | | public string Position { get; set; } |
| | | 43 | | |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Электронная почта |
| | | 47 | | /// </summary> |
| | | 48 | | [CrmMap, CrmOnlyLoad] |
| | 0 | 49 | | public string Email { get; set; } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Телефон |
| | | 53 | | /// </summary> |
| | | 54 | | [CrmMap("MobilePhone"), CrmOnlyLoad] |
| | 0 | 55 | | public string Phone { get; set; } |
| | | 56 | | |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Контрагент |
| | | 60 | | /// </summary> |
| | 1342 | 61 | | public Contragent Contragent { get; set; } |
| | | 62 | | |
| | | 63 | | |
| | | 64 | | /// <summary> |
| | | 65 | | /// Контактное лицо |
| | | 66 | | /// </summary> |
| | | 67 | | [Required] |
| | 0 | 68 | | public bool IsContactPerson { get; set; } = false; |
| | | 69 | | |
| | | 70 | | /// <summary> |
| | | 71 | | /// Признак блокировки |
| | | 72 | | /// </summary> |
| | | 73 | | [Required] |
| | 0 | 74 | | public bool IsBlocked { get; set; } = false; |
| | | 75 | | |
| | | 76 | | /// <summary> |
| | | 77 | | /// Подразделения |
| | | 78 | | /// </summary> |
| | 0 | 79 | | public List<UserDepartment> UsersDepartments { get; set; } |
| | | 80 | | |
| | | 81 | | /// <summary> |
| | | 82 | | /// Роли |
| | | 83 | | /// </summary> |
| | 0 | 84 | | public List<UserRole> UsersRoles { get; set; } |
| | | 85 | | |
| | | 86 | | /// <summary> |
| | | 87 | | /// Внешний ключ для CRM |
| | | 88 | | /// </summary> |
| | | 89 | | // [Required] |
| | | 90 | | [CrmKey("NrbTID"), CrmOnlyLoad] |
| | | 91 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | 0 | 92 | | public Guid ExternalKey { get; set; } |
| | | 93 | | |
| | | 94 | | public string GetFio() |
| | 0 | 95 | | { |
| | 0 | 96 | | string result = ""; |
| | 0 | 97 | | if (!string.IsNullOrWhiteSpace(this.FirstName)) |
| | 0 | 98 | | result += this.FirstName.Substring(0, 1).ToUpper() + "."; |
| | 0 | 99 | | if (!string.IsNullOrWhiteSpace(this.MiddleName)) |
| | 0 | 100 | | result += this.MiddleName.Substring(0, 1).ToUpper() + "."; |
| | 0 | 101 | | if (!string.IsNullOrWhiteSpace(this.LastName)) |
| | 0 | 102 | | result += this.LastName; |
| | 0 | 103 | | return result; |
| | 0 | 104 | | } |
| | | 105 | | |
| | 0 | 106 | | public string GetName() => this.LastName + " " + this.FirstName; |
| | | 107 | | } |
| | | 108 | | } |
| | | 109 | | |