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

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

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