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

Integrated Applications Programming Company

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.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-SERVICEVOIP 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 OntServiceVoip
  29:      {
  30:          /// <summary/>
  31:          public OntServiceVoip() { }
  32:   
  33:          /// <summary/>
  34:          [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
  35:          public string Id { get; set; }
  36:   
  37:          /// <summary/>
  38:          public int StateId { get; set; }
  39:   
  40:          /// <summary/>
  41:          public int Svlan { get; set; }
  42:   
  43:          /// <summary/>
  44:          public string Ip { get; set; }
  45:   
  46:          /// <summary/>
  47:          public string FtpIp { get; set; }
  48:   
  49:          /// <summary/>
  50:          public string MgcIp { get; set; }
  51:   
  52:          /// <summary/>
  53:          public string MgcSecondaryIp { get; set; }
  54:   
  55:          /// <summary/>
  56:          public string ConfiguratinFile { get; set; }
  57:   
  58:          /// <summary/>
  59:          public string Customer { get; set; }
  60:   
  61:          /// <summary/>
  62:          public string Label { 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(OntServiceVoip ontServiceVoip, 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:                  ontServiceVoip.Created = ontServiceVoip.Updated = DateTime.UtcNow.AddHours(3);
 106:   
 107:                  db.OntServiceVoips.Add(ontServiceVoip);
 108:                  db.SaveChanges();
 109:   
 110:                  b = true;
 111:              }
 112:   
 113:              return b;
 114:          }
 115:   
 116:          ////////////////////////////////////////////////////////////////////////////
 117:   
 118:          /// <summary>
 119:          ///
 120:          /// </summary>
 121:          public static OntServiceVoip Read(string id)
 122:          {
 123:              OntServiceVoip ontServiceVoip;
 124:   
 125:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 126:              {
 127:                  ontServiceVoip = (from osv in db.OntServiceVoips where osv.Id == id select osv).SingleOrDefault();
 128:              }
 129:   
 130:              return ontServiceVoip;
 131:          }
 132:   
 133:          ////////////////////////////////////////////////////////////////////////////
 134:   
 135:          /// <summary>
 136:          ///
 137:          /// </summary>
 138:          public static List<OntServiceVoip> ReadList()
 139:          {
 140:              List<OntServiceVoip> ontServiceVoipList;
 141:   
 142:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 143:              {
 144:                  ontServiceVoipList = (from osv in db.OntServiceVoips select osv).ToList();
 145:              }
 146:   
 147:              return ontServiceVoipList;
 148:          }
 149:   
 150:          ////////////////////////////////////////////////////////////////////////////
 151:   
 152:          /// <summary>
 153:          ///
 154:          /// </summary>
 155:          public static bool Update(OntServiceVoip ontServiceVoip, 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:                  ontServiceVoip = (from osv in db.OntServiceVoips where osv.Id == ontServiceVoip.Id select osv).SingleOrDefault();
 165:   
 166:                  ontServiceVoip.Updated = DateTime.UtcNow.AddHours(3);
 167:   
 168:                  db.OntServiceVoips.Attach(ontServiceVoip);
 169:   
 170:                  db.Entry(ontServiceVoip).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 osv in db.OntServiceVoips where osv.Id == id select osv).FirstOrDefault();
 194:   
 195:                  db.OntServiceVoips.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(OntServiceVoip 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(OntServiceVoip b)
 228:          {
 229:              // below: this will not update Id, Created
 230:              bool updated;
 231:   
 232:              updated = false;
 233:   
 234:              if (this.ConfiguratinFile != b.ConfiguratinFile) { this.ConfiguratinFile = b.ConfiguratinFile; updated = true; }
 235:              if (this.Customer != b.Customer) { this.Customer = b.Customer; updated = true; }
 236:              if (this.FtpIp != b.FtpIp) { this.FtpIp = b.FtpIp; updated = true; }
 237:              if (this.Ip != b.Ip) { this.Ip = b.Ip; updated = true; }
 238:              if (this.Label != b.Label) { this.Label = b.Label; updated = true; }
 239:              if (this.MgcIp != b.MgcIp) { this.MgcIp = b.MgcIp; updated = true; }
 240:              if (this.MgcSecondaryIp != b.MgcSecondaryIp) { this.MgcSecondaryIp = b.MgcSecondaryIp; updated = true; }
 241:   
 242:              if (this.Ont != b.Ont) { this.Ont = b.Ont; updated = true; }
 243:              if (this.StateId != b.StateId) { this.StateId = b.StateId; updated = true; }
 244:              if (this.Svlan != b.Svlan) { this.Svlan = b.Svlan; updated = true; }
 245:              if (this.UserId != b.UserId) { this.UserId = b.UserId; 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.OntServiceVoip.ToSimpleTextString(this);
 261:          }
 262:   
 263:          ////////////////////////////////////////////////////////////////////////////
 264:          ////////////////////////////////////////////////////////////////////////////
 265:      }
 266:   
 267:      ////////////////////////////////////////////////////////////////////////////
 268:      ////////////////////////////////////////////////////////////////////////////
 269:  }