شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة ش.ش.و.

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Staff

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

Staff Entity Framework class for Optical Fiber Network (OFN) entity model.

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