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