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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » Contact

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

Contact Entity Framework class for Optical Fiber Network (OFN) 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.Ngn.Cl.Model
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// Contact Entity Framework class for Optical Fiber Network (OFN) 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:          public System.Guid UserId { get; set; }
  77:   
  78:          /// <summary/>
  79:          [NotMapped]
  80:          public string FullName
  81:          {
  82:              get
  83:              {
  84:                  string fullName;
  85:   
  86:                  fullName = FirstName + " " + MiddleName + " " + LastName;
  87:   
  88:                  fullName = fullName.Replace("  ", " ");
  89:   
  90:                  return fullName;
  91:              }
  92:          }
  93:   
  94:          /// <summary/>
  95:          [NotMapped]
  96:          public string FirstAndMiddleName
  97:          {
  98:              get
  99:              {
 100:                  string firstAndMiddleName;
 101:   
 102:                  firstAndMiddleName = FirstName + " " + MiddleName;
 103:   
 104:                  firstAndMiddleName = firstAndMiddleName.Replace("  ", " ");
 105:   
 106:                  return firstAndMiddleName;
 107:              }
 108:          }
 109:   
 110:          ////////////////////////////////////////////////////////////////////////////
 111:   
 112:          /// <summary>
 113:          ///
 114:          /// </summary>
 115:          public bool Update(Contact updatedContact)
 116:          {
 117:              // below: this will not update Id, Created
 118:              bool updated;
 119:   
 120:              updated = false;
 121:   
 122:              if (this.Address != updatedContact.Address) { this.Address = updatedContact.Address; updated = true; }
 123:              if (this.Company != updatedContact.Company) { this.Company = updatedContact.Company; updated = true; }
 124:              if (this.CountryId != updatedContact.CountryId) { this.CountryId = updatedContact.CountryId; updated = true; }
 125:              if (this.Email != updatedContact.Email) { this.Email = updatedContact.Email; updated = true; }
 126:              if (this.FirstName != updatedContact.FirstName) { this.FirstName = updatedContact.FirstName; updated = true; }
 127:              if (this.IsApproved != updatedContact.IsApproved) { this.IsApproved = updatedContact.IsApproved; updated = true; }
 128:              if (this.LastName != updatedContact.LastName) { this.LastName = updatedContact.LastName; updated = true; }
 129:              if (this.MiddleName != updatedContact.MiddleName) { this.MiddleName = updatedContact.MiddleName; updated = true; }
 130:              if (this.Note != updatedContact.Note) { this.Note = updatedContact.Note; updated = true; }
 131:              if (this.Phone != updatedContact.Phone) { this.Phone = updatedContact.Phone; updated = true; }
 132:              if (this.Url != updatedContact.Url) { this.Url = updatedContact.Url; updated = true; }
 133:              if (this.UserId != updatedContact.UserId) { this.UserId = updatedContact.UserId; updated = true; }
 134:   
 135:              if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
 136:   
 137:              return updated;
 138:          }
 139:   
 140:          ////////////////////////////////////////////////////////////////////////////
 141:          ////////////////////////////////////////////////////////////////////////////
 142:      }
 143:   
 144:      ////////////////////////////////////////////////////////////////////////////
 145:      ////////////////////////////////////////////////////////////////////////////
 146:  }