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

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

Subscriber Entity Framework class for Fixed Telecommunications Network (FTN) data model.

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Linq;
    4:  
    5: namespace Ia.Ftn.Cl.Models.Data.Nokia
    6: {
    7:     ////////////////////////////////////////////////////////////////////////////
    8:  
    9:     /// <summary publish="true">
   10:     /// Subscriber Entity Framework class for Fixed Telecommunications Network (FTN) data model.
   11:     /// </summary>
   12:     /// 
   13:     /// <remarks> 
   14:     /// Copyright � 2014-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   15:     /// </remarks> 
   16:     public class Subscriber
   17:     {
   18:         /// <summary/>
   19:         public Subscriber() { }
   20:  
   21:         ////////////////////////////////////////////////////////////////////////////
   22:  
   23:         /// <summary>
   24:         /// 
   25:         /// </summary>
   26:         public static bool Create(Ia.Ftn.Cl.Models.Nokia.Subscriber subscriber, out string result)
   27:         {
   28:             bool b;
   29:  
   30:             b = false;
   31:             result = string.Empty;
   32:  
   33:             using (var db = new Ia.Ftn.Cl.Db())
   34:             {
   35:                 subscriber.Created = subscriber.Updated = DateTime.UtcNow.AddHours(3);
   36:  
   37:                 db.Subscribers.Add(subscriber);
   38:                 db.SaveChanges();
   39:  
   40:                 b = true;
   41:             }
   42:  
   43:             return b;
   44:         }
   45:  
   46:         ////////////////////////////////////////////////////////////////////////////
   47:  
   48:         /// <summary>
   49:         /// 
   50:         /// </summary>
   51:         public static Ia.Ftn.Cl.Models.Nokia.Subscriber Read(string id)
   52:         {
   53:             Ia.Ftn.Cl.Models.Nokia.Subscriber subscriber;
   54:  
   55:             using (var db = new Ia.Ftn.Cl.Db())
   56:             {
   57:                 subscriber = (from s in db.Subscribers where s.Id == id select s).SingleOrDefault();
   58:             }
   59:  
   60:             return subscriber;
   61:         }
   62:  
   63:         ////////////////////////////////////////////////////////////////////////////
   64:  
   65:         /// <summary>
   66:         /// 
   67:         /// </summary>
   68:         public static List<Ia.Ftn.Cl.Models.Nokia.Subscriber> ReadList()
   69:         {
   70:             List<Ia.Ftn.Cl.Models.Nokia.Subscriber> subscriberList;
   71:  
   72:             using (var db = new Ia.Ftn.Cl.Db())
   73:             {
   74:                 subscriberList = (from s in db.Subscribers select s).ToList();
   75:             }
   76:  
   77:             return subscriberList;
   78:         }
   79:  
   80:         ////////////////////////////////////////////////////////////////////////////
   81:  
   82:         /// <summary>
   83:         /// 
   84:         /// </summary>
   85:         public static bool Update(Ia.Ftn.Cl.Models.Nokia.Subscriber subscriber, 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:                 subscriber = (from s in db.Subscribers where s.Id == subscriber.Id select s).SingleOrDefault();
   95:  
   96:                 subscriber.Updated = DateTime.UtcNow.AddHours(3);
   97:  
   98:                 db.Subscribers.Attach(subscriber);
   99:  
  100:                 db.Entry(subscriber).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  101:                 db.SaveChanges();
  102:  
  103:                 b = true;
  104:             }
  105:  
  106:             return b;
  107:         }
  108:  
  109:         ////////////////////////////////////////////////////////////////////////////
  110:  
  111:         /// <summary>
  112:         /// 
  113:         /// </summary>
  114:         public static bool Delete(string id, out string result)
  115:         {
  116:             bool b;
  117:  
  118:             b = false;
  119:             result = string.Empty;
  120:  
  121:             using (var db = new Ia.Ftn.Cl.Db())
  122:             {
  123:                 var v = (from s in db.Subscribers where s.Id == id select s).FirstOrDefault();
  124:  
  125:                 db.Subscribers.Remove(v);
  126:                 db.SaveChanges();
  127:  
  128:                 b = true;
  129:             }
  130:  
  131:             return b;
  132:         }
  133:  
  134:         ////////////////////////////////////////////////////////////////////////////
  135:         ////////////////////////////////////////////////////////////////////////////
  136:     }
  137:  
  138:     ////////////////////////////////////////////////////////////////////////////
  139:     ////////////////////////////////////////////////////////////////////////////
  140: }