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

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), 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 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:   
  43:          /// <summary/>
  44:          public int StateId { get; set; }
  45:   
  46:          /// <summary/>
  47:          public int Card { get; set; }
  48:   
  49:          /// <summary/>
  50:          public int Port { get; set; }
  51:   
  52:          /// <summary/>
  53:          public string Termination { get; set; }
  54:   
  55:          /// <summary/>
  56:          public string Tn { get; set; }
  57:   
  58:          /// <summary/>
  59:          public int Svlan { get; set; }
  60:   
  61:          /// <summary/>
  62:          public string VoipClientIp { get; set; }
  63:   
  64:          /// <summary/>
  65:          public string Customer { get; set; }
  66:   
  67:          /// <summary/>
  68:          public DateTime Created { get; set; }
  69:   
  70:          /// <summary/>
  71:          public DateTime Updated { get; set; }
  72:   
  73:          /// <summary/>
  74:          public System.Guid UserId { get; set; }
  75:   
  76:          /// <summary/>
  77:          public virtual Ont Ont { get; set; }
  78:   
  79:          ////////////////////////////////////////////////////////////////////////////
  80:   
  81:          /// <summary>
  82:          ///
  83:          /// </summary>
  84:          [NotMapped]
  85:          public string State
  86:          {
  87:              get
  88:              {
  89:                  return Ia.Ngn.Cl.Model.Data.Nokia.Ams.BellcoreStateFromId(this.StateId);
  90:              }
  91:          }
  92:   
  93:          ////////////////////////////////////////////////////////////////////////////
  94:   
  95:          /// <summary>
  96:          ///
  97:          /// </summary>
  98:          public static bool Create(OntOntPots ontOntPots, out string result)
  99:          {
 100:              bool b;
 101:   
 102:              b = false;
 103:              result = string.Empty;
 104:   
 105:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 106:              {
 107:                  ontOntPots.Created = ontOntPots.Updated = DateTime.UtcNow.AddHours(3);
 108:   
 109:                  db.OntOntPotses.Add(ontOntPots);
 110:                  db.SaveChanges();
 111:   
 112:                  b = true;
 113:              }
 114:   
 115:              return b;
 116:          }
 117:   
 118:          ////////////////////////////////////////////////////////////////////////////
 119:   
 120:          /// <summary>
 121:          ///
 122:          /// </summary>
 123:          public static OntOntPots Read(string id)
 124:          {
 125:              OntOntPots ontOntPots;
 126:   
 127:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 128:              {
 129:                  ontOntPots = (from oop in db.OntOntPotses where oop.Id == id select oop).SingleOrDefault();
 130:              }
 131:   
 132:              return ontOntPots;
 133:          }
 134:   
 135:          ////////////////////////////////////////////////////////////////////////////
 136:   
 137:          /// <summary>
 138:          ///
 139:          /// </summary>
 140:          public static List<OntOntPots> ReadList()
 141:          {
 142:              List<OntOntPots> ontList;
 143:   
 144:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 145:              {
 146:                  ontList = (from oop in db.OntOntPotses select oop).ToList();
 147:              }
 148:   
 149:              return ontList;
 150:          }
 151:   
 152:          ////////////////////////////////////////////////////////////////////////////
 153:   
 154:          /// <summary>
 155:          ///
 156:          /// </summary>
 157:          public static bool Update(OntOntPots ontOntPots, out string result)
 158:          {
 159:              bool b;
 160:   
 161:              b = false;
 162:              result = string.Empty;
 163:   
 164:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 165:              {
 166:                  ontOntPots = (from oop in db.OntOntPotses where oop.Id == ontOntPots.Id select oop).SingleOrDefault();
 167:   
 168:                  ontOntPots.Updated = DateTime.UtcNow.AddHours(3);
 169:   
 170:                  db.OntOntPotses.Attach(ontOntPots);
 171:   
 172:                  db.Entry(ontOntPots).State = System.Data.Entity.EntityState.Modified;
 173:                  db.SaveChanges();
 174:   
 175:                  b = true;
 176:              }
 177:   
 178:              return b;
 179:          }
 180:   
 181:          ////////////////////////////////////////////////////////////////////////////
 182:   
 183:          /// <summary>
 184:          ///
 185:          /// </summary>
 186:          public static bool Delete(string id, out string result)
 187:          {
 188:              bool b;
 189:   
 190:              b = false;
 191:              result = string.Empty;
 192:   
 193:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 194:              {
 195:                  var v = (from o in db.Onts where o.Id == id select o).FirstOrDefault();
 196:   
 197:                  db.Onts.Remove(v);
 198:                  db.SaveChanges();
 199:   
 200:                  b = true;
 201:              }
 202:   
 203:              return b;
 204:          }
 205:   
 206:   
 207:          ////////////////////////////////////////////////////////////////////////////
 208:   
 209:          /// <summary>
 210:          ///
 211:          /// </summary>
 212:          public bool Equal(OntOntPots b)
 213:          {
 214:              // below: this will not check the Id, Created, Updated fields
 215:              bool areEqual;
 216:   
 217:              //if (this.BatteryBackupAvailable != b.BatteryBackupAvailable) areEqual = false;
 218:              /*else*/
 219:              areEqual = true;
 220:   
 221:              return areEqual;
 222:          }
 223:   
 224:          ////////////////////////////////////////////////////////////////////////////
 225:   
 226:          /// <summary>
 227:          ///
 228:          /// </summary>
 229:          public bool Update(OntOntPots b)
 230:          {
 231:              // below: this will not update Id, Created
 232:              bool updated;
 233:   
 234:              updated = false;
 235:   
 236:              //if (this.StateId != b.StateId) { this.StateId = b.StateId;b = true;}
 237:              if (this.Card != b.Card) { this.Card = b.Card; updated = true; }
 238:              if (this.Customer != b.Customer) { this.Customer = b.Customer; updated = true; }
 239:              if (this.Ont != b.Ont) { this.Ont = b.Ont; updated = true; }
 240:              if (this.Port != b.Port) { this.Port = b.Port; updated = true; }
 241:              if (this.StateId != b.StateId) { this.StateId = b.StateId; updated = true; }
 242:              if (this.Svlan != b.Svlan) { this.Svlan = b.Svlan; updated = true; }
 243:   
 244:              if (this.Termination != b.Termination) { this.Termination = b.Termination; updated = true; }
 245:              if (this.Tn != b.Tn) { this.Tn = b.Tn; updated = true; }
 246:              if (this.UserId != b.UserId) { this.UserId = b.UserId; updated = true; }
 247:              if (this.VoipClientIp != b.VoipClientIp) { this.VoipClientIp = b.VoipClientIp; updated = true; }
 248:   
 249:              if (updated) this.Updated = DateTime.UtcNow.AddHours(3);
 250:   
 251:              return updated;
 252:          }
 253:   
 254:          ////////////////////////////////////////////////////////////////////////////
 255:          ////////////////////////////////////////////////////////////////////////////
 256:   
 257:          /// <summary>
 258:          ///
 259:          /// </summary>
 260:          public string ToSimpleTextString()
 261:          {
 262:              return Ia.Ngn.Cl.Model.Data.Nokia.OntOntPots.ToSimpleTextString(this);
 263:          }
 264:   
 265:          ////////////////////////////////////////////////////////////////////////////
 266:          ////////////////////////////////////////////////////////////////////////////
 267:      }
 268:   
 269:      ////////////////////////////////////////////////////////////////////////////
 270:      ////////////////////////////////////////////////////////////////////////////
 271:  }