1: using System;
2: using System.Collections.Generic;
3: using System.ComponentModel.DataAnnotations.Schema;
4:
5: namespace Ia.Ngn.Cl.Model
6: {
7: ////////////////////////////////////////////////////////////////////////////
8:
9: /// <summary publish="true">
10: /// Staff Entity Framework class for Next Generation Network (NGN) entity model.
11: /// </summary>
12: ///
13: /// <remarks>
14: /// Copyright © 2006-2020 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
15: ///
16: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
17: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
18: ///
19: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
20: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21: ///
22: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
23: ///
24: /// Copyright notice: This notice may not be removed or altered from any source distribution.
25: /// </remarks>
26: public partial class Staff
27: {
28: /// <summary/>
29: public Staff() { }
30:
31: /// <summary/>
32: public int Id { get; set; }
33:
34: /// <summary/>
35: public bool IsHead { get; set; }
36:
37: /// <summary/>
38: public int AdministrativeFrameworkId { get; set; }
39:
40: /// <summary/>
41: public string FirstName { get; set; }
42:
43: /// <summary/>
44: public string MiddleName { get; set; }
45:
46: /// <summary/>
47: public string LastName { get; set; }
48:
49: /// <summary/>
50: public int EmploymentId { get; set; }
51:
52: /// <summary/>
53: public DateTime? EmploymentDate { get; set; }
54:
55: /// <summary/>
56: public string IpPbxExtension { get; set; }
57:
58: /// <summary/>
59: public DateTime Created { get; set; }
60:
61: /// <summary/>
62: public DateTime Updated { get; set; }
63:
64: /// <summary/>
65: public System.Guid UserId { get; set; }
66:
67: /// <summary/>
68: [NotMapped]
69: public string FullName
70: {
71: get
72: {
73: string fullName;
74:
75: fullName = FirstName + " " + MiddleName + " " + LastName;
76:
77: fullName = fullName.Replace(" ", " ");
78:
79: return fullName;
80: }
81: }
82:
83: /// <summary/>
84: [NotMapped]
85: public string FirstAndMiddleName
86: {
87: get
88: {
89: string firstAndMiddleName;
90:
91: firstAndMiddleName = FirstName + " " + MiddleName;
92:
93: firstAndMiddleName = firstAndMiddleName.Replace(" ", " ");
94:
95: return firstAndMiddleName;
96: }
97: }
98:
99: /// <summary/>
100: [NotMapped]
101: public string FirstAndMiddleNameBracketFrameworkArabicNameAndFrameworkParentArabicNameBracket
102: {
103: get
104: {
105: string name;
106:
107: name = FirstAndMiddleName + " (" + Framework.ArabicName + " " + Framework.Parent.ArabicName + ")";
108:
109: return name;
110: }
111: }
112:
113: /// <summary/>
114: [NotMapped]
115: public virtual Ia.Ngn.Cl.Model.Business.Administration.Framework Framework { get; set; }
116:
117: /// <summary/>
118: [NotMapped]
119: public Staff Head { get; set; }
120:
121: /// <summary/>
122: [NotMapped]
123: public List<Staff> Heads { get; set; }
124:
125: /// <summary/>
126: [NotMapped]
127: public List<Staff> Colleagues { get; set; }
128:
129: /// <summary/>
130: [NotMapped]
131: public List<Staff> Subordinates { get; set; }
132:
133: /// <summary/>
134: [NotMapped]
135: public Ia.Cl.Model.Identity.User User { get; set; }
136:
137: ////////////////////////////////////////////////////////////////////////////
138:
139: /// <summary>
140: ///
141: /// </summary>
142: public bool Update(Ia.Ngn.Cl.Model.Staff updatedStaff)
143: {
144: // below: this will not update Id, Created
145: bool updated;
146:
147: updated = false;
148:
149: if (this.FirstName != updatedStaff.FirstName) { this.FirstName = updatedStaff.FirstName; updated = true; }
150: if (this.MiddleName != updatedStaff.MiddleName) { this.MiddleName = updatedStaff.MiddleName; updated = true; }
151: if (this.LastName != updatedStaff.LastName) { this.LastName = updatedStaff.LastName; updated = true; }
152: if (this.EmploymentId != updatedStaff.EmploymentId) { this.EmploymentId = updatedStaff.EmploymentId; updated = true; }
153: if (this.EmploymentDate != updatedStaff.EmploymentDate) { this.EmploymentDate = updatedStaff.EmploymentDate; updated = true; }
154: if (this.IpPbxExtension != updatedStaff.IpPbxExtension) { this.IpPbxExtension = updatedStaff.IpPbxExtension; updated = true; }
155: if (this.IsHead != updatedStaff.IsHead) { this.IsHead = updatedStaff.IsHead; updated = true; }
156: if (this.AdministrativeFrameworkId != updatedStaff.AdministrativeFrameworkId) { this.AdministrativeFrameworkId = updatedStaff.AdministrativeFrameworkId; updated = true; }
157: if (this.UserId != updatedStaff.UserId) { this.UserId = updatedStaff.UserId; updated = true; }
158:
159: if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
160:
161: return updated;
162: }
163:
164: ////////////////////////////////////////////////////////////////////////////
165: ////////////////////////////////////////////////////////////////////////////
166: }
167:
168: ////////////////////////////////////////////////////////////////////////////
169: ////////////////////////////////////////////////////////////////////////////
170: }