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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » OntOntPots

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

ONT-ONTPOTS Entity Framework class for Next Generation Network (NGN) entity model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.ComponentModel.DataAnnotations;
   4:  using System.ComponentModel.DataAnnotations.Schema;
   5:  using System.Linq;
   6:   
   7:  namespace Ia.Ngn.Cl.Model
   8:  {
   9:      ////////////////////////////////////////////////////////////////////////////
  10:   
  11:      /// <summary publish="true">
  12:      /// ONT-ONTPOTS Entity Framework class for Next Generation Network (NGN) entity model.
  13:      /// </summary>
  14:      /// 
  15:      /// <remarks> 
  16:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet 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 partial class OntOntPots
  29:      {
  30:          /// <summary/>
  31:          public OntOntPots()
  32:          {
  33:              //this.OntServiceHsi = new List<OntServiceHsi>();
  34:          }
  35:   
  36:          /// <summary/>
  37:          public enum FamilyType { Sfu = 1, Soho = 2, Mdu = 3 };
  38:   
  39:          /// <summary/>
  40:          [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
  41:          public string Id { get; set; }
  42:          /// <summary/>
  43:          public int StateId { get; set; }
  44:          /// <summary/>
  45:          public int Card { get; set; }
  46:          /// <summary/>
  47:          public int Port { get; set; }
  48:          /// <summary/>
  49:          public string Termination { get; set; }
  50:          /// <summary/>
  51:          public string Tn { get; set; }
  52:          /// <summary/>
  53:          public int Svlan { get; set; }
  54:          /// <summary/>
  55:          public string VoipClientIp { get; set; }
  56:          /// <summary/>
  57:          public string Customer { get; set; }
  58:          /// <summary/>
  59:          public DateTime Created { get; set; }
  60:          /// <summary/>
  61:          public DateTime Updated { get; set; }
  62:          /// <summary/>
  63:          public System.Guid UserId { get; set; }
  64:   
  65:          /// <summary/>
  66:          public virtual Ont Ont { get; set; }
  67:   
  68:          ////////////////////////////////////////////////////////////////////////////
  69:   
  70:          /// <summary>
  71:          ///
  72:          /// </summary>
  73:          [NotMapped]
  74:          public string State
  75:          {
  76:              get
  77:              {
  78:                  return Ia.Ngn.Cl.Model.Data.Nokia.Ams.BellcoreStateFromId(this.StateId);
  79:              }
  80:          }
  81:   
  82:          ////////////////////////////////////////////////////////////////////////////
  83:   
  84:          /// <summary>
  85:          ///
  86:          /// </summary>
  87:          public static bool Create(OntOntPots ontOntPots, out string result)
  88:          {
  89:              bool b;
  90:   
  91:              b = false;
  92:              result = string.Empty;
  93:   
  94:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  95:              {
  96:                  ontOntPots.Created = ontOntPots.Updated = DateTime.UtcNow.AddHours(3);
  97:   
  98:                  db.OntOntPotses.Add(ontOntPots);
  99:                  db.SaveChanges();
 100:   
 101:                  b = true;
 102:              }
 103:   
 104:              return b;
 105:          }
 106:   
 107:          ////////////////////////////////////////////////////////////////////////////
 108:   
 109:          /// <summary>
 110:          ///
 111:          /// </summary>
 112:          public static OntOntPots Read(string id)
 113:          {
 114:              OntOntPots ontOntPots;
 115:   
 116:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 117:              {
 118:                  ontOntPots = (from oop in db.OntOntPotses where oop.Id == id select oop).SingleOrDefault();
 119:              }
 120:   
 121:              return ontOntPots;
 122:          }
 123:   
 124:          ////////////////////////////////////////////////////////////////////////////
 125:   
 126:          /// <summary>
 127:          ///
 128:          /// </summary>
 129:          public static List<OntOntPots> ReadList()
 130:          {
 131:              List<OntOntPots> ontList;
 132:   
 133:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 134:              {
 135:                  ontList = (from oop in db.OntOntPotses select oop).ToList();
 136:              }
 137:   
 138:              return ontList;
 139:          }
 140:   
 141:          ////////////////////////////////////////////////////////////////////////////
 142:   
 143:          /// <summary>
 144:          ///
 145:          /// </summary>
 146:          public static bool Update(OntOntPots ontOntPots, out string result)
 147:          {
 148:              bool b;
 149:   
 150:              b = false;
 151:              result = string.Empty;
 152:   
 153:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 154:              {
 155:                  ontOntPots = (from oop in db.OntOntPotses where oop.Id == ontOntPots.Id select oop).SingleOrDefault();
 156:   
 157:                  ontOntPots.Updated = DateTime.UtcNow.AddHours(3);
 158:   
 159:                  db.OntOntPotses.Attach(ontOntPots);
 160:   
 161:                  db.Entry(ontOntPots).State = System.Data.Entity.EntityState.Modified;
 162:                  db.SaveChanges();
 163:   
 164:                  b = true;
 165:              }
 166:   
 167:              return b;
 168:          }
 169:   
 170:          ////////////////////////////////////////////////////////////////////////////
 171:   
 172:          /// <summary>
 173:          ///
 174:          /// </summary>
 175:          public static bool Delete(string id, out string result)
 176:          {
 177:              bool b;
 178:   
 179:              b = false;
 180:              result = string.Empty;
 181:   
 182:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 183:              {
 184:                  var v = (from o in db.Onts where o.Id == id select o).FirstOrDefault();
 185:   
 186:                  db.Onts.Remove(v);
 187:                  db.SaveChanges();
 188:   
 189:                  b = true;
 190:              }
 191:   
 192:              return b;
 193:          }
 194:   
 195:   
 196:          ////////////////////////////////////////////////////////////////////////////
 197:   
 198:          /// <summary>
 199:          ///
 200:          /// </summary>
 201:          public bool Equal(OntOntPots b)
 202:          {
 203:              // below: this will not check the Id, Created, Updated fields
 204:              bool areEqual;
 205:   
 206:              //if (this.BatteryBackupAvailable != b.BatteryBackupAvailable) areEqual = false;
 207:              /*else*/
 208:              areEqual = true;
 209:   
 210:              return areEqual;
 211:          }
 212:   
 213:          ////////////////////////////////////////////////////////////////////////////
 214:   
 215:          /// <summary>
 216:          ///
 217:          /// </summary>
 218:          public bool Update(OntOntPots b)
 219:          {
 220:              // below: this will not update Id, Created
 221:              bool updated;
 222:   
 223:              updated = false;
 224:   
 225:              //if (this.StateId != b.StateId) { this.StateId = b.StateId;b = true;}
 226:              if (this.Card != b.Card) { this.Card = b.Card; updated = true; }
 227:              if (this.Customer != b.Customer) { this.Customer = b.Customer; updated = true; }
 228:              if (this.Ont != b.Ont) { this.Ont = b.Ont; updated = true; }
 229:              if (this.Port != b.Port) { this.Port = b.Port; updated = true; }
 230:              if (this.StateId != b.StateId) { this.StateId = b.StateId; updated = true; }
 231:              if (this.Svlan != b.Svlan) { this.Svlan = b.Svlan; updated = true; }
 232:   
 233:              if (this.Termination != b.Termination) { this.Termination = b.Termination; updated = true; }
 234:              if (this.Tn != b.Tn) { this.Tn = b.Tn; updated = true; }
 235:              if (this.UserId != b.UserId) { this.UserId = b.UserId; updated = true; }
 236:              if (this.VoipClientIp != b.VoipClientIp) { this.VoipClientIp = b.VoipClientIp; updated = true; }
 237:   
 238:              if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
 239:   
 240:              return updated;
 241:          }
 242:   
 243:          ////////////////////////////////////////////////////////////////////////////
 244:          ////////////////////////////////////////////////////////////////////////////
 245:   
 246:          /// <summary>
 247:          ///
 248:          /// </summary>
 249:          public string ToSimpleTextString()
 250:          {
 251:              return Ia.Ngn.Cl.Model.Data.Nokia.OntOntPots.ToSimpleTextString(this);
 252:          }
 253:   
 254:          ////////////////////////////////////////////////////////////////////////////
 255:          ////////////////////////////////////////////////////////////////////////////
 256:      }
 257:   
 258:      ////////////////////////////////////////////////////////////////////////////
 259:      ////////////////////////////////////////////////////////////////////////////
 260:  }