Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
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.Linq;
   4:  using System.Web;
   5:  using System.Web.Security;
   6:  using System.ComponentModel.DataAnnotations;
   7:  using System.ComponentModel.DataAnnotations.Schema;
   8:   
   9:  namespace Ia.Ngn.Cl.Model
  10:  {
  11:      ////////////////////////////////////////////////////////////////////////////
  12:   
  13:      /// <summary publish="true">
  14:      /// ONT-ONTPOTS Entity Framework class for Next Generation Network (NGN) entity model.
  15:      /// </summary>
  16:      /// 
  17:      /// <remarks> 
  18:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  19:      ///
  20:      /// 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
  21:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  22:      ///
  23:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  24:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  25:      /// 
  26:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  27:      /// 
  28:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  29:      /// </remarks> 
  30:      public partial class OntOntPots
  31:      {
  32:          /// <summary/>
  33:          public OntOntPots() 
  34:          {
  35:              //this.OntServiceHsi = new List<OntServiceHsi>();
  36:          }
  37:   
  38:          /// <summary/>
  39:          public enum FamilyType { Sfu = 1, Soho = 2, Mdu = 3 };
  40:   
  41:          /// <summary/>
  42:          [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
  43:          public string Id { get; set; }
  44:          /// <summary/>
  45:          public int StateId { get; set; }
  46:          /// <summary/>
  47:          public int Card { get; set; }
  48:          /// <summary/>
  49:          public int Port { get; set; }
  50:          /// <summary/>
  51:          public string Termination { get; set; }
  52:          /// <summary/>
  53:          public string Tn { get; set; }
  54:          /// <summary/>
  55:          public int Svlan { get; set; }
  56:          /// <summary/>
  57:          public string VoipClientIp { get; set; }
  58:          /// <summary/>
  59:          public string Customer { 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 Ont Ont { get; set; }
  69:   
  70:          ////////////////////////////////////////////////////////////////////////////
  71:   
  72:          /// <summary>
  73:          ///
  74:          /// </summary>
  75:          [NotMapped]
  76:          public string State
  77:          {
  78:              get
  79:              {
  80:                  return Ia.Ngn.Cl.Model.Data.Nokia.Ams.BellcoreStateFromId(this.StateId);
  81:              }
  82:          }
  83:   
  84:          ////////////////////////////////////////////////////////////////////////////
  85:   
  86:          /// <summary>
  87:          ///
  88:          /// </summary>
  89:          public static bool Create(OntOntPots ontOntPots, out string result)
  90:          {
  91:              bool b;
  92:   
  93:              b = false;
  94:              result = "";
  95:   
  96:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  97:              {
  98:                  ontOntPots.Created = ontOntPots.Updated = DateTime.UtcNow.AddHours(3);
  99:   
 100:                  db.OntOntPotses.Add(ontOntPots);
 101:                  db.SaveChanges();
 102:   
 103:                  b = true;
 104:              }
 105:   
 106:              return b;
 107:          }
 108:   
 109:          ////////////////////////////////////////////////////////////////////////////
 110:   
 111:          /// <summary>
 112:          ///
 113:          /// </summary>
 114:          public static OntOntPots Read(string id)
 115:          {
 116:              OntOntPots ontOntPots;
 117:   
 118:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 119:              {
 120:                  ontOntPots = (from oop in db.OntOntPotses where oop.Id == id select oop).SingleOrDefault();
 121:              }
 122:   
 123:              return ontOntPots;
 124:          }
 125:   
 126:          ////////////////////////////////////////////////////////////////////////////
 127:   
 128:          /// <summary>
 129:          ///
 130:          /// </summary>
 131:          public static List<OntOntPots> ReadList()
 132:          {
 133:              List<OntOntPots> ontList;
 134:   
 135:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 136:              {
 137:                  ontList = (from oop in db.OntOntPotses select oop).ToList();
 138:              }
 139:   
 140:              return ontList;
 141:          }
 142:   
 143:          ////////////////////////////////////////////////////////////////////////////
 144:   
 145:          /// <summary>
 146:          ///
 147:          /// </summary>
 148:          public static bool Update(OntOntPots ontOntPots, out string result)
 149:          {
 150:              bool b;
 151:   
 152:              b = false;
 153:              result = "";
 154:   
 155:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 156:              {
 157:                  ontOntPots = (from oop in db.OntOntPotses where oop.Id == ontOntPots.Id select oop).SingleOrDefault();
 158:   
 159:                  ontOntPots.Updated = DateTime.UtcNow.AddHours(3);
 160:   
 161:                  db.OntOntPotses.Attach(ontOntPots);
 162:   
 163:                  db.Entry(ontOntPots).State = System.Data.Entity.EntityState.Modified;
 164:                  db.SaveChanges();
 165:   
 166:                  b = true;
 167:              }
 168:   
 169:              return b;
 170:          }
 171:   
 172:          ////////////////////////////////////////////////////////////////////////////
 173:   
 174:          /// <summary>
 175:          ///
 176:          /// </summary>
 177:          public static bool Delete(string id, out string result)
 178:          {
 179:              bool b;
 180:   
 181:              b = false;
 182:              result = "";
 183:   
 184:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 185:              {
 186:                  var v = (from o in db.Onts where o.Id == id select o).FirstOrDefault();
 187:   
 188:                  db.Onts.Remove(v);
 189:                  db.SaveChanges();
 190:   
 191:                  b = true;
 192:              }
 193:   
 194:              return b;
 195:          }
 196:   
 197:   
 198:          ////////////////////////////////////////////////////////////////////////////
 199:   
 200:          /// <summary>
 201:          ///
 202:          /// </summary>
 203:          public bool Equal(OntOntPots b)
 204:          {
 205:              // below: this will not check the Id, Created, Updated fields
 206:              bool areEqual;
 207:   
 208:              //if (this.BatteryBackupAvailable != b.BatteryBackupAvailable) areEqual = false;
 209:              /*else*/ areEqual = true;
 210:   
 211:              return areEqual;
 212:          }
 213:   
 214:          ////////////////////////////////////////////////////////////////////////////
 215:   
 216:          /// <summary>
 217:          ///
 218:          /// </summary>
 219:          public bool Update(OntOntPots b)
 220:          {
 221:              // below: this will not update Id, Created
 222:              bool updated;
 223:   
 224:              updated = false;
 225:   
 226:              //if (this.StateId != b.StateId) { this.StateId = b.StateId;b = true;}
 227:              if (this.Card != b.Card) { this.Card = b.Card; updated = true; }
 228:              if (this.Customer != b.Customer) { this.Customer = b.Customer; updated = true; }
 229:              if (this.Ont != b.Ont) { this.Ont = b.Ont; updated = true; }
 230:              if (this.Port != b.Port) { this.Port = b.Port; updated = true; }
 231:              if (this.StateId != b.StateId) { this.StateId = b.StateId; updated = true; }
 232:              if (this.Svlan != b.Svlan) { this.Svlan = b.Svlan; updated = true; }
 233:   
 234:              if (this.Termination != b.Termination) { this.Termination = b.Termination; updated = true; }
 235:              if (this.Tn != b.Tn) { this.Tn = b.Tn; updated = true; }
 236:              if (this.UserId != b.UserId) { this.UserId = b.UserId; updated = true; }
 237:              if (this.VoipClientIp != b.VoipClientIp) { this.VoipClientIp = b.VoipClientIp; updated = true; }
 238:   
 239:              if(updated) this.Updated = DateTime.UtcNow.AddHours(3);
 240:   
 241:              return updated;
 242:          }
 243:   
 244:          ////////////////////////////////////////////////////////////////////////////
 245:          ////////////////////////////////////////////////////////////////////////////
 246:   
 247:          /// <summary>
 248:          ///
 249:          /// </summary>
 250:          public string ToSimpleTextString()
 251:          {
 252:              return Ia.Ngn.Cl.Model.Data.Nokia.OntOntPots.ToSimpleTextString(this);
 253:          }
 254:   
 255:          ////////////////////////////////////////////////////////////////////////////
 256:          ////////////////////////////////////////////////////////////////////////////
 257:      }
 258:   
 259:      ////////////////////////////////////////////////////////////////////////////
 260:      ////////////////////////////////////////////////////////////////////////////
 261:  }