)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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:     ///
   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 StaffIdentityUser : IdentityUser
   31:     {
   32:         /// <summary/>
   33:         public StaffIdentityUser() { }
   34:  
   35:         /// <summary/>
   36:         //public string Id { get; set; } inherited from IdentityUser
   37:  
   38:         /// <summary/>
   39:         //public string UserName { get; set; } inherited from IdentityUser
   40:  
   41:         /// <summary/>
   42:         //public string Email { get; set; } inherited from IdentityUser
   43:  
   44:         /// <summary/>
   45:         public bool IsHead { get; set; }
   46:  
   47:         /// <summary/>
   48:         public string FrameworkId { get; set; }
   49:  
   50:         /// <summary/>
   51:         public string FirstName { get; set; }
   52:  
   53:         /// <summary/>
   54:         public string MiddleName { get; set; }
   55:  
   56:         /// <summary/>
   57:         public string LastName { get; set; }
   58:  
   59:         /// <summary/>
   60:         public DateTime Created { get; set; }
   61:  
   62:         /// <summary/>
   63:         public DateTime Updated { get; set; }
   64:  
   65:         /// <summary/>
   66:         [NotMapped]
   67:         public string FullName
   68:         {
   69:             get
   70:             {
   71:                 string fullName;
   72:  
   73:                 fullName = FirstName + " " + MiddleName + " " + LastName;
   74:  
   75:                 fullName = fullName.Replace("  ", " ");
   76:  
   77:                 return fullName;
   78:             }
   79:         }
   80:  
   81:         /// <summary/>
   82:         [NotMapped]
   83:         public string FirstAndMiddleName
   84:         {
   85:             get
   86:             {
   87:                 string firstAndMiddleName;
   88:  
   89:                 firstAndMiddleName = FirstName + " " + MiddleName;
   90:  
   91:                 firstAndMiddleName = firstAndMiddleName.Replace("  ", " ");
   92:  
   93:                 return firstAndMiddleName;
   94:             }
   95:         }
   96:  
   97:         /// <summary/>
   98:         [NotMapped]
   99:         public string FirstAndMiddleNameBracketFrameworkArabicNameAndFrameworkParentArabicNameBracket
  100:         {
  101:             get
  102:             {
  103:                 string name;
  104:  
  105:                 if (Framework != null)
  106:                 {
  107:                     if (Framework.Parent != null)
  108:                     {
  109:                         name = FirstAndMiddleName + " (" + Framework.ArabicName + " " + Framework.Parent.ArabicName + ")";
  110:                     }
  111:                     else name = FirstAndMiddleName + " (" + Framework.ArabicName + ")";
  112:                 }
  113:                 else name = FirstAndMiddleName;
  114:  
  115:                 return name;
  116:             }
  117:         }
  118:  
  119:         /// <summary/>
  120:         [NotMapped]
  121:         public virtual Ia.Ftn.Cl.Models.Business.Administration.Framework Framework { get; set; }
  122:  
  123:         /// <summary/>
  124:         [NotMapped]
  125:         public StaffIdentityUser Head { get; set; }
  126:  
  127:         /// <summary/>
  128:         [NotMapped]
  129:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> Heads { get; set; }
  130:  
  131:         /// <summary/>
  132:         [NotMapped]
  133:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> HeadsOrSelf { get; set; }
  134:  
  135:         /// <summary/>
  136:         [NotMapped]
  137:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> Colleagues { get; set; }
  138:  
  139:         /// <summary/>
  140:         [NotMapped]
  141:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> ColleaguesOrSelf { get; set; }
  142:  
  143:         /// <summary/>
  144:         [NotMapped]
  145:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> Subordinates { get; set; }
  146:  
  147:         /// <summary/>
  148:         [NotMapped]
  149:         public List<Ia.Ftn.Cl.Models.StaffIdentityUser> SubordinatesOrSelf { get; set; }
  150:  
  151:         /// <summary/>
  152:         [NotMapped]
  153:         public string FirstAndMiddleNameBracketUserName
  154:         {
  155:             get
  156:             {
  157:                 string firstAndMiddleName;
  158:  
  159:                 firstAndMiddleName = FirstName + " " + MiddleName;
  160:  
  161:                 firstAndMiddleName = firstAndMiddleName.Replace("  ", " ");
  162:  
  163:                 return firstAndMiddleName + " (" + UserName + ")";
  164:             }
  165:         }
  166:  
  167:         ////////////////////////////////////////////////////////////////////////////
  168:  
  169:         /// <summary>
  170:         ///
  171:         /// </summary>
  172:         public bool Update(Ia.Ftn.Cl.Models.StaffIdentityUser updatedStaff)
  173:         {
  174:             // below: this will not update Id, Created
  175:             bool updated;
  176:  
  177:             updated = false;
  178:  
  179:             if (this.FirstName != updatedStaff.FirstName) { this.FirstName = updatedStaff.FirstName; updated = true; }
  180:             if (this.MiddleName != updatedStaff.MiddleName) { this.MiddleName = updatedStaff.MiddleName; updated = true; }
  181:             if (this.LastName != updatedStaff.LastName) { this.LastName = updatedStaff.LastName; updated = true; }
  182:             if (this.IsHead != updatedStaff.IsHead) { this.IsHead = updatedStaff.IsHead; updated = true; }
  183:             if (this.FrameworkId != updatedStaff.FrameworkId) { this.FrameworkId = updatedStaff.FrameworkId; updated = true; }
  184:  
  185:             if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
  186:  
  187:             return updated;
  188:         }
  189:  
  190:         ////////////////////////////////////////////////////////////////////////////
  191:         ////////////////////////////////////////////////////////////////////////////
  192:     }
  193:  
  194:     ////////////////////////////////////////////////////////////////////////////
  195:     ////////////////////////////////////////////////////////////////////////////
  196: }