)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » OntServiceVoip (Ia.Ftn.Cl.Models)

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

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