)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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:     ///
   18:     /// 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
   19:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   20:     ///
   21:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   22:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   23:     /// 
   24:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   25:     /// 
   26:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   27:     /// </remarks> 
   28:     public class Contact
   29:     {
   30:         /// <summary/>
   31:         public Contact() { }
   32:  
   33:         /// <summary/>
   34:         public int Id { get; set; }
   35:  
   36:         /// <summary/>
   37:         public string FirstName { get; set; }
   38:  
   39:         /// <summary/>
   40:         public string MiddleName { get; set; }
   41:  
   42:         /// <summary/>
   43:         public string LastName { get; set; }
   44:  
   45:         /// <summary/>
   46:         public string Company { get; set; }
   47:  
   48:         /// <summary/>
   49:         public string Email { get; set; }
   50:  
   51:         /// <summary/>
   52:         public string Phone { get; set; }
   53:  
   54:         /// <summary/>
   55:         public string Address { get; set; }
   56:  
   57:         /// <summary/>
   58:         public int CountryId { get; set; }
   59:  
   60:         /// <summary/>
   61:         public string Url { get; set; }
   62:  
   63:         /// <summary/>
   64:         public bool IsApproved { get; set; }
   65:  
   66:         /// <summary/>
   67:         public string Note { get; set; }
   68:  
   69:         /// <summary/>
   70:         public DateTime Created { get; set; }
   71:  
   72:         /// <summary/>
   73:         public DateTime Updated { get; set; }
   74:  
   75:         /// <summary/>
   76:         [ForeignKey("StaffIdentityUser_Id")]
   77:         public virtual StaffIdentityUser StaffIdentityUser { get; set; }
   78:  
   79:         /// <summary/>
   80:         [NotMapped]
   81:         public string FullName
   82:         {
   83:             get
   84:             {
   85:                 string fullName;
   86:  
   87:                 fullName = FirstName + " " + MiddleName + " " + LastName;
   88:  
   89:                 fullName = fullName.Replace("  ", " ");
   90:  
   91:                 return fullName;
   92:             }
   93:         }
   94:  
   95:         /// <summary/>
   96:         [NotMapped]
   97:         public string FirstAndMiddleName
   98:         {
   99:             get
  100:             {
  101:                 string firstAndMiddleName;
  102:  
  103:                 firstAndMiddleName = FirstName + " " + MiddleName;
  104:  
  105:                 firstAndMiddleName = firstAndMiddleName.Replace("  ", " ");
  106:  
  107:                 return firstAndMiddleName;
  108:             }
  109:         }
  110:  
  111:         ////////////////////////////////////////////////////////////////////////////
  112:  
  113:         /// <summary>
  114:         ///
  115:         /// </summary>
  116:         public bool Update(Contact updatedContact)
  117:         {
  118:             // below: this will not update Id, Created
  119:             bool updated;
  120:  
  121:             updated = false;
  122:  
  123:             if (this.Address != updatedContact.Address) { this.Address = updatedContact.Address; updated = true; }
  124:             if (this.Company != updatedContact.Company) { this.Company = updatedContact.Company; updated = true; }
  125:             if (this.CountryId != updatedContact.CountryId) { this.CountryId = updatedContact.CountryId; updated = true; }
  126:             if (this.Email != updatedContact.Email) { this.Email = updatedContact.Email; updated = true; }
  127:             if (this.FirstName != updatedContact.FirstName) { this.FirstName = updatedContact.FirstName; updated = true; }
  128:             if (this.IsApproved != updatedContact.IsApproved) { this.IsApproved = updatedContact.IsApproved; updated = true; }
  129:             if (this.LastName != updatedContact.LastName) { this.LastName = updatedContact.LastName; updated = true; }
  130:             if (this.MiddleName != updatedContact.MiddleName) { this.MiddleName = updatedContact.MiddleName; updated = true; }
  131:             if (this.Note != updatedContact.Note) { this.Note = updatedContact.Note; updated = true; }
  132:             if (this.Phone != updatedContact.Phone) { this.Phone = updatedContact.Phone; updated = true; }
  133:             if (this.Url != updatedContact.Url) { this.Url = updatedContact.Url; updated = true; }
  134:             if (this.StaffIdentityUser.Id != updatedContact.StaffIdentityUser.Id) { this.StaffIdentityUser.Id = updatedContact.StaffIdentityUser.Id; updated = true; }
  135:  
  136:             if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
  137:  
  138:             return updated;
  139:         }
  140:  
  141:         ////////////////////////////////////////////////////////////////////////////
  142:         ////////////////////////////////////////////////////////////////////////////
  143:     }
  144:  
  145:     ////////////////////////////////////////////////////////////////////////////
  146:     ////////////////////////////////////////////////////////////////////////////
  147: }