)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Staff (Ia.Ftn.Cl.Model)

Public general use code classes and xml files that we've compiled and used over the years:

Staff Entity Framework class for Fixed Telecommunications Network (FTN) entity model.

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