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