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

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

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

    1: using System;
    2: using System.ComponentModel.DataAnnotations.Schema;
    3: using System.Linq;
    4: using System.Threading;
    5: using System.Threading.Tasks;
    6:  
    7: namespace Ia.Ftn.Cl.Models
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     /// Contact Entity Framework class for Fixed Telecommunications Network (FTN) entity model.
   13:     /// </summary>
   14:     /// 
   15:     /// <remarks> 
   16:     /// Copyright © 2006-2021 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   17:     /// </remarks> 
   18:     public class Contact
   19:     {
   20:         /// <summary/>
   21:         public Contact() { }
   22:  
   23:         /// <summary/>
   24:         public int Id { get; set; }
   25:  
   26:         /// <summary/>
   27:         public string FirstName { get; set; }
   28:  
   29:         /// <summary/>
   30:         public string MiddleName { get; set; }
   31:  
   32:         /// <summary/>
   33:         public string LastName { get; set; }
   34:  
   35:         /// <summary/>
   36:         public string Company { get; set; }
   37:  
   38:         /// <summary/>
   39:         public string Email { get; set; }
   40:  
   41:         /// <summary/>
   42:         public string Phone { get; set; }
   43:  
   44:         /// <summary/>
   45:         public string Address { get; set; }
   46:  
   47:         /// <summary/>
   48:         public int CountryId { get; set; }
   49:  
   50:         /// <summary/>
   51:         public string Url { get; set; }
   52:  
   53:         /// <summary/>
   54:         public bool IsApproved { get; set; }
   55:  
   56:         /// <summary/>
   57:         public string Note { get; set; }
   58:  
   59:         /// <summary/>
   60:         public DateTime Created { get; set; }
   61:  
   62:         /// <summary/>
   63:         public DateTime Updated { get; set; }
   64:  
   65:         /// <summary/>
   66:         [ForeignKey("StaffIdentityUser_Id")]
   67:         public virtual StaffIdentityUser StaffIdentityUser { get; set; }
   68:  
   69:         /// <summary/>
   70:         [NotMapped]
   71:         public string FullName
   72:         {
   73:             get
   74:             {
   75:                 string fullName;
   76:  
   77:                 fullName = FirstName + " " + MiddleName + " " + LastName;
   78:  
   79:                 fullName = fullName.Replace("  ", " ");
   80:  
   81:                 return fullName;
   82:             }
   83:         }
   84:  
   85:         /// <summary/>
   86:         [NotMapped]
   87:         public string FirstAndMiddleName
   88:         {
   89:             get
   90:             {
   91:                 string firstAndMiddleName;
   92:  
   93:                 firstAndMiddleName = FirstName + " " + MiddleName;
   94:  
   95:                 firstAndMiddleName = firstAndMiddleName.Replace("  ", " ");
   96:  
   97:                 return firstAndMiddleName;
   98:             }
   99:         }
  100:  
  101:         ////////////////////////////////////////////////////////////////////////////
  102:  
  103:         /// <summary>
  104:         ///
  105:         /// </summary>
  106:         public bool Update(Contact updatedContact)
  107:         {
  108:             // below: this will not update Id, Created
  109:             bool updated;
  110:  
  111:             updated = false;
  112:  
  113:             if (this.Address != updatedContact.Address) { this.Address = updatedContact.Address; updated = true; }
  114:             if (this.Company != updatedContact.Company) { this.Company = updatedContact.Company; updated = true; }
  115:             if (this.CountryId != updatedContact.CountryId) { this.CountryId = updatedContact.CountryId; updated = true; }
  116:             if (this.Email != updatedContact.Email) { this.Email = updatedContact.Email; updated = true; }
  117:             if (this.FirstName != updatedContact.FirstName) { this.FirstName = updatedContact.FirstName; updated = true; }
  118:             if (this.IsApproved != updatedContact.IsApproved) { this.IsApproved = updatedContact.IsApproved; updated = true; }
  119:             if (this.LastName != updatedContact.LastName) { this.LastName = updatedContact.LastName; updated = true; }
  120:             if (this.MiddleName != updatedContact.MiddleName) { this.MiddleName = updatedContact.MiddleName; updated = true; }
  121:             if (this.Note != updatedContact.Note) { this.Note = updatedContact.Note; updated = true; }
  122:             if (this.Phone != updatedContact.Phone) { this.Phone = updatedContact.Phone; updated = true; }
  123:             if (this.Url != updatedContact.Url) { this.Url = updatedContact.Url; updated = true; }
  124:             if (this.StaffIdentityUser.Id != updatedContact.StaffIdentityUser.Id) { this.StaffIdentityUser.Id = updatedContact.StaffIdentityUser.Id; updated = true; }
  125:  
  126:             if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
  127:  
  128:             return updated;
  129:         }
  130:  
  131:         ////////////////////////////////////////////////////////////////////////////
  132:         ////////////////////////////////////////////////////////////////////////////
  133:     }
  134:  
  135:     ////////////////////////////////////////////////////////////////////////////
  136:     ////////////////////////////////////////////////////////////////////////////
  137: }