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

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.AspNetCore.Identity;
    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.Models
   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-2024 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   19:     /// </remarks> 
   20:     public class StaffIdentityUser : IdentityUser
   21:     {
   22:         /// <summary/>
   23:         public StaffIdentityUser() { }
   24:  
   25:         /// <summary/>
   26:         //public string Id { get; set; } inherited from IdentityUser
   27:  
   28:         /// <summary/>
   29:         //public string UserName { get; set; } inherited from IdentityUser
   30:  
   31:         /// <summary/>
   32:         //public string Email { get; set; } inherited from IdentityUser
   33:  
   34:         /// <summary/>
   35:         public bool IsHead { get; set; }
   36:  
   37:         /// <summary/>
   38:         public string FrameworkId { 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 DateTime Created { get; set; }
   51:  
   52:         /// <summary/>
   53:         public DateTime Updated { get; set; }
   54:  
   55:         /// <summary/>
   56:         [NotMapped]
   57:         public string FullName
   58:         {
   59:             get
   60:             {
   61:                 string fullName;
   62:  
   63:                 fullName = FirstName + " " + MiddleName + " " + LastName;
   64:  
   65:                 fullName = fullName.Replace("  ", " ");
   66:  
   67:                 return fullName;
   68:             }
   69:         }
   70:  
   71:         /// <summary/>
   72:         [NotMapped]
   73:         public string FirstAndMiddleName
   74:         {
   75:             get
   76:             {
   77:                 string firstAndMiddleName;
   78:  
   79:                 firstAndMiddleName = FirstName + " " + MiddleName;
   80:  
   81:                 firstAndMiddleName = firstAndMiddleName.Replace("  ", " ");
   82:  
   83:                 return firstAndMiddleName;
   84:             }
   85:         }
   86:  
   87:         /// <summary/>
   88:         [NotMapped]
   89:         public string FirstAndMiddleNameBracketFrameworkArabicNameAndFrameworkParentArabicNameBracket
   90:         {
   91:             get
   92:             {
   93:                 string name;
   94:  
   95:                 if (Framework != null)
   96:                 {
   97:                     if (Framework.Parent != null)
   98:                     {
   99:                         name = FirstAndMiddleName + " (" + Framework.ArabicName + " " + Framework.Parent.ArabicName + ")";
  100:                     }
  101:                     else name = FirstAndMiddleName + " (" + Framework.ArabicName + ")";
  102:                 }
  103:                 else name = FirstAndMiddleName;
  104:  
  105:                 return name;
  106:             }
  107:         }
  108:  
  109:         /// <summary/>
  110:         [NotMapped]
  111:         public virtual Ia.Ftn.Cl.Models.Business.Administration.Framework Framework { get; set; }
  112:  
  113:         /// <summary/>
  114:         [NotMapped]
  115:         public StaffIdentityUser Head { get; set; }
  116:  
  117:         /// <summary/>
  118:         [NotMapped]
  119:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> Heads { get; set; }
  120:  
  121:         /// <summary/>
  122:         [NotMapped]
  123:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> HeadsOrSelf { get; set; }
  124:  
  125:         /// <summary/>
  126:         [NotMapped]
  127:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> Colleagues { get; set; }
  128:  
  129:         /// <summary/>
  130:         [NotMapped]
  131:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> ColleaguesOrSelf { get; set; }
  132:  
  133:         /// <summary/>
  134:         [NotMapped]
  135:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> Subordinates { get; set; }
  136:  
  137:         /// <summary/>
  138:         [NotMapped]
  139:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> SubordinatesOrSelf { get; set; }
  140:  
  141:         /// <summary/>
  142:         [NotMapped]
  143:         public string FirstAndMiddleNameBracketUserName
  144:         {
  145:             get
  146:             {
  147:                 string firstAndMiddleName;
  148:  
  149:                 firstAndMiddleName = FirstName + " " + MiddleName;
  150:  
  151:                 firstAndMiddleName = firstAndMiddleName.Replace("  ", " ");
  152:  
  153:                 return firstAndMiddleName + " (" + UserName + ")";
  154:             }
  155:         }
  156:  
  157:         ////////////////////////////////////////////////////////////////////////////
  158:  
  159:         /// <summary>
  160:         ///
  161:         /// </summary>
  162:         public bool Update(Ia.Ftn.Cl.Models.StaffIdentityUser 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.IsHead != updatedStaff.IsHead) { this.IsHead = updatedStaff.IsHead; updated = true; }
  173:             if (this.FrameworkId != updatedStaff.FrameworkId) { this.FrameworkId = updatedStaff.FrameworkId; updated = true; }
  174:  
  175:             if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
  176:  
  177:             return updated;
  178:         }
  179:  
  180:         ////////////////////////////////////////////////////////////////////////////
  181:         ////////////////////////////////////////////////////////////////////////////
  182:     }
  183:  
  184:     ////////////////////////////////////////////////////////////////////////////
  185:     ////////////////////////////////////////////////////////////////////////////
  186: }