Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
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 Next Generation Network (NGN) entity model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Web;
   5:  using System.Web.Security;
   6:  using System.ComponentModel.DataAnnotations.Schema;
   7:   
   8:  namespace Ia.Ngn.Cl.Model
   9:  {
  10:      ////////////////////////////////////////////////////////////////////////////
  11:   
  12:      /// <summary publish="true">
  13:      /// Contact Entity Framework class for Next Generation Network (NGN) entity model.
  14:      /// </summary>
  15:      /// 
  16:      /// <remarks> 
  17:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  18:      ///
  19:      /// 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
  20:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  21:      ///
  22:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  23:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  24:      /// 
  25:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  26:      /// 
  27:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  28:      /// </remarks> 
  29:      public partial class Contact
  30:      {
  31:          /// <summary/>
  32:          public Contact() {}
  33:   
  34:          /// <summary/>
  35:          public int Id { get; set; }
  36:   
  37:          /// <summary/>
  38:          public string FirstName { get; set; }
  39:   
  40:          /// <summary/>
  41:          public string MiddleName { get; set; }
  42:   
  43:          /// <summary/>
  44:          public string LastName { get; set; }
  45:   
  46:          /// <summary/>
  47:          public string Company { get; set; }
  48:   
  49:          /// <summary/>
  50:          public string Email { get; set; }
  51:   
  52:          /// <summary/>
  53:          public string Phone { get; set; }
  54:   
  55:          /// <summary/>
  56:          public string Address { get; set; }
  57:   
  58:          /// <summary/>
  59:          public int CountryId { get; set; }
  60:   
  61:          /// <summary/>
  62:          public string Url { get; set; }
  63:   
  64:          /// <summary/>
  65:          public bool IsApproved { get; set; }
  66:   
  67:          /// <summary/>
  68:          public string Note { get; set; }
  69:   
  70:          /// <summary/>
  71:          public DateTime Created { get; set; }
  72:   
  73:          /// <summary/>
  74:          public DateTime Updated { get; set; }
  75:   
  76:          /// <summary/>
  77:          public System.Guid UserId { 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.UserId != updatedContact.UserId) { this.UserId = updatedContact.UserId; 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:  }