Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Access

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

Access 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.ComponentModel.DataAnnotations;
   5:  using System.ComponentModel.DataAnnotations.Schema;
   6:  using System.Text;
   7:   
   8:  namespace Ia.Ngn.Cl.Model
   9:  {
  10:      ////////////////////////////////////////////////////////////////////////////
  11:   
  12:      /// <summary publish="true">
  13:      /// Access Entity Framework class for Next Generation Network (NGN) entity model.
  14:      /// </summary>
  15:      /// 
  16:      /// <remarks> 
  17:      /// Copyright © 2006-2018 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 Access
  30:      {
  31:          /// <summary/>
  32:          public Access() { }
  33:   
  34:          /// <summary/>
  35:          [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
  36:          public string Id { get; set; }
  37:   
  38:          /// <summary/>
  39:          public int Olt { get; set; }
  40:          /// <summary/>
  41:          public int Pon { get; set; }
  42:          /// <summary/>
  43:          public int Ont { get; set; }
  44:          /// <summary/>
  45:          public string Odf { get; set; }
  46:          /// <summary/>
  47:          public int AreaId { get; set; }
  48:          /// <summary/>
  49:          public string Block { get; set; }
  50:          /// <summary/>
  51:          public string Street { get; set; }
  52:          /// <summary/>
  53:          public string PremisesOld { get; set; }
  54:          /// <summary/>
  55:          public string PremisesNew { get; set; }
  56:          /// <summary/>
  57:          public string Paci { get; set; }
  58:          /// <summary/>
  59:          public string Note { get; set; }
  60:          /// <summary/>
  61:          public DateTime Created { get; set; }
  62:          /// <summary/>
  63:          public DateTime Updated { get; set; }
  64:          /// <summary/>
  65:          public System.Guid UserId { get; set; }
  66:   
  67:          /// <summary/>
  68:          public virtual ICollection<Ont> Onts { get; set; }
  69:   
  70:          /// <summary/>
  71:          public virtual ICollection<Ia.Ngn.Cl.Model.Huawei.EmsOnt> EmsOnts { get; set; }
  72:   
  73:          /// <summary/>
  74:          [NotMapped]
  75:          public string Name
  76:          {
  77:              get
  78:              {
  79:                  return Ia.Ngn.Cl.Model.Business.Access.Name(this);
  80:              }
  81:          }
  82:   
  83:          /// <summary/>
  84:          [NotMapped]
  85:          public string Position
  86:          {
  87:              get
  88:              {
  89:                  string position;
  90:   
  91:                  position = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Pon.PonGroup.Olt.Id == this.Olt && o.Pon.Number == this.Pon && o.Number == this.Ont select o.Position).SingleOrDefault();
  92:   
  93:                  return position;
  94:              }
  95:          }
  96:   
  97:          /// <summary/>
  98:          [NotMapped]
  99:          public string Address
 100:          {
 101:              get
 102:              {
 103:                  string address;
 104:   
 105:                  address = (from kna in Ia.Ngn.Cl.Model.Data.Service.KuwaitNgnAreaList where kna.Id == this.AreaId select kna.Name).SingleOrDefault();
 106:   
 107:                  address += ", block " + this.Block + ", street " + this.Street + ", old premises " + this.PremisesOld + ", new premises " + this.PremisesNew;
 108:   
 109:                  return address;
 110:              }
 111:          }
 112:   
 113:           ////////////////////////////////////////////////////////////////////////////
 114:   
 115:          /// <summary>
 116:          ///
 117:          /// </summary>
 118:          public bool Update(Access updatedAccess)
 119:          {
 120:              // below: this will not update Id, Created
 121:              bool updated;
 122:   
 123:              updated = false;
 124:   
 125:              if (this.AreaId != updatedAccess.AreaId) { this.AreaId = updatedAccess.AreaId; updated = true; }
 126:              if (this.Block != updatedAccess.Block) { this.Block = updatedAccess.Block; updated = true; }
 127:              //if (this.Name != updatedAccess.Name) { this.Name = updatedAccess.Name; updated = true; }
 128:              if (this.Odf != updatedAccess.Odf) { this.Odf = updatedAccess.Odf; updated = true; }
 129:              if (this.Olt != updatedAccess.Olt) { this.Olt = updatedAccess.Olt; updated = true; }
 130:              if (this.Ont != updatedAccess.Ont) { this.Ont = updatedAccess.Ont; updated = true; }
 131:              if (this.Pon != updatedAccess.Pon) { this.Pon = updatedAccess.Pon; updated = true; }
 132:              //if (this.Position != updatedAccess.Position) { this.Position = updatedAccess.Position; updated = true; }
 133:              if (this.PremisesOld != updatedAccess.PremisesOld) { this.PremisesOld = updatedAccess.PremisesOld; updated = true; }
 134:              if (this.PremisesNew != updatedAccess.PremisesNew) { this.PremisesNew = updatedAccess.PremisesNew; updated = true; }
 135:              if (this.Paci != updatedAccess.Paci) { this.Paci = updatedAccess.Paci; updated = true; }
 136:              if (this.Note != updatedAccess.Note) { this.Note = updatedAccess.Note; updated = true; }
 137:              if (this.Street != updatedAccess.Street) { this.Street = updatedAccess.Street; updated = true; }
 138:              if (this.UserId != updatedAccess.UserId) { this.UserId = updatedAccess.UserId; updated = true; }
 139:   
 140:              if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
 141:   
 142:              return updated;
 143:          }
 144:   
 145:          ////////////////////////////////////////////////////////////////////////////
 146:          ////////////////////////////////////////////////////////////////////////////
 147:   
 148:          /// <summary>
 149:          ///
 150:          /// </summary>
 151:          public string ToSimpleTextString()
 152:          {
 153:              return Ia.Ngn.Cl.Model.Data.Access.ToSimpleTextString(this);
 154:          }
 155:   
 156:          ////////////////////////////////////////////////////////////////////////////
 157:          ////////////////////////////////////////////////////////////////////////////
 158:      }
 159:   
 160:      ////////////////////////////////////////////////////////////////////////////
 161:      ////////////////////////////////////////////////////////////////////////////
 162:  }