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

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

ONT-ONTPOTS 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-ONTPOTS 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 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:         [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(OntOntPots ontOntPots, 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:                 ontOntPots.Created = ontOntPots.Updated = DateTime.UtcNow.AddHours(3);
  105:  
  106:                 db.OntOntPots.Add(ontOntPots);
  107:                 db.SaveChanges();
  108:  
  109:                 b = true;
  110:             }
  111:  
  112:             return b;
  113:         }
  114:  
  115:         ////////////////////////////////////////////////////////////////////////////
  116:  
  117:         /// <summary>
  118:         ///
  119:         /// </summary>
  120:         public static OntOntPots Read(string id)
  121:         {
  122:             OntOntPots ontOntPots;
  123:  
  124:             using (var db = new Ia.Ftn.Cl.Db())
  125:             {
  126:                 ontOntPots = (from oop in db.OntOntPots where oop.Id == id select oop).SingleOrDefault();
  127:             }
  128:  
  129:             return ontOntPots;
  130:         }
  131:  
  132:         ////////////////////////////////////////////////////////////////////////////
  133:  
  134:         /// <summary>
  135:         ///
  136:         /// </summary>
  137:         public static List<OntOntPots> ReadList()
  138:         {
  139:             List<OntOntPots> ontList;
  140:  
  141:             using (var db = new Ia.Ftn.Cl.Db())
  142:             {
  143:                 ontList = (from oop in db.OntOntPots select oop).ToList();
  144:             }
  145:  
  146:             return ontList;
  147:         }
  148:  
  149:         ////////////////////////////////////////////////////////////////////////////
  150:  
  151:         /// <summary>
  152:         ///
  153:         /// </summary>
  154:         public static bool Update(OntOntPots ontOntPots, 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:                 ontOntPots = (from oop in db.OntOntPots where oop.Id == ontOntPots.Id select oop).SingleOrDefault();
  164:  
  165:                 ontOntPots.Updated = DateTime.UtcNow.AddHours(3);
  166:  
  167:                 db.OntOntPots.Attach(ontOntPots);
  168:  
  169:                 db.Entry(ontOntPots).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 o in db.Onts where o.Id == id select o).FirstOrDefault();
  193:  
  194:                 db.Onts.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(OntOntPots 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(OntOntPots b)
  227:         {
  228:             // below: this will not update Id, Created
  229:             bool updated;
  230:  
  231:             updated = false;
  232:  
  233:             //if (this.StateId != b.StateId) { this.StateId = b.StateId;b = true;}
  234:             if (this.Card != b.Card) { this.Card = b.Card; updated = true; }
  235:             if (this.Customer != b.Customer) { this.Customer = b.Customer; updated = true; }
  236:             if (this.Ont != b.Ont) { this.Ont = b.Ont; updated = true; }
  237:             if (this.Port != b.Port) { this.Port = b.Port; updated = true; }
  238:             if (this.StateId != b.StateId) { this.StateId = b.StateId; updated = true; }
  239:             if (this.Svlan != b.Svlan) { this.Svlan = b.Svlan; updated = true; }
  240:  
  241:             if (this.Termination != b.Termination) { this.Termination = b.Termination; updated = true; }
  242:             if (this.Tn != b.Tn) { this.Tn = b.Tn; updated = true; }
  243:             if (this.VoipClientIp != b.VoipClientIp) { this.VoipClientIp = b.VoipClientIp; 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.OntOntPots.ToSimpleTextString(this);
  259:         }
  260:  
  261:         ////////////////////////////////////////////////////////////////////////////
  262:         ////////////////////////////////////////////////////////////////////////////
  263:     }
  264:  
  265:     ////////////////////////////////////////////////////////////////////////////
  266:     ////////////////////////////////////////////////////////////////////////////
  267: }