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

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