)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Subscriber (Ia.Ftn.Cl.Model.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.Model.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:     ///
   16:     /// 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
   17:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   18:     ///
   19:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   20:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   21:     /// 
   22:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   23:     /// 
   24:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   25:     /// </remarks> 
   26:     public class Subscriber
   27:     {
   28:         /// <summary/>
   29:         public Subscriber() { }
   30:  
   31:         ////////////////////////////////////////////////////////////////////////////
   32:  
   33:         /// <summary>
   34:         /// 
   35:         /// </summary>
   36:         public static bool Create(Ia.Ftn.Cl.Model.Nokia.Subscriber subscriber, out string result)
   37:         {
   38:             bool b;
   39:  
   40:             b = false;
   41:             result = string.Empty;
   42:  
   43:             using (var db = new Ia.Ftn.Cl.Model.Db())
   44:             {
   45:                 subscriber.Created = subscriber.Updated = DateTime.UtcNow.AddHours(3);
   46:  
   47:                 db.Subscribers.Add(subscriber);
   48:                 db.SaveChanges();
   49:  
   50:                 b = true;
   51:             }
   52:  
   53:             return b;
   54:         }
   55:  
   56:         ////////////////////////////////////////////////////////////////////////////
   57:  
   58:         /// <summary>
   59:         /// 
   60:         /// </summary>
   61:         public static Ia.Ftn.Cl.Model.Nokia.Subscriber Read(string id)
   62:         {
   63:             Ia.Ftn.Cl.Model.Nokia.Subscriber subscriber;
   64:  
   65:             using (var db = new Ia.Ftn.Cl.Model.Db())
   66:             {
   67:                 subscriber = (from s in db.Subscribers where s.Id == id select s).SingleOrDefault();
   68:             }
   69:  
   70:             return subscriber;
   71:         }
   72:  
   73:         ////////////////////////////////////////////////////////////////////////////
   74:  
   75:         /// <summary>
   76:         /// 
   77:         /// </summary>
   78:         public static List<Ia.Ftn.Cl.Model.Nokia.Subscriber> ReadList()
   79:         {
   80:             List<Ia.Ftn.Cl.Model.Nokia.Subscriber> subscriberList;
   81:  
   82:             using (var db = new Ia.Ftn.Cl.Model.Db())
   83:             {
   84:                 subscriberList = (from s in db.Subscribers select s).ToList();
   85:             }
   86:  
   87:             return subscriberList;
   88:         }
   89:  
   90:         ////////////////////////////////////////////////////////////////////////////
   91:  
   92:         /// <summary>
   93:         /// 
   94:         /// </summary>
   95:         public static bool Update(Ia.Ftn.Cl.Model.Nokia.Subscriber subscriber, out string result)
   96:         {
   97:             bool b;
   98:  
   99:             b = false;
  100:             result = string.Empty;
  101:  
  102:             using (var db = new Ia.Ftn.Cl.Model.Db())
  103:             {
  104:                 subscriber = (from s in db.Subscribers where s.Id == subscriber.Id select s).SingleOrDefault();
  105:  
  106:                 subscriber.Updated = DateTime.UtcNow.AddHours(3);
  107:  
  108:                 db.Subscribers.Attach(subscriber);
  109:  
  110:                 db.Entry(subscriber).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
  111:                 db.SaveChanges();
  112:  
  113:                 b = true;
  114:             }
  115:  
  116:             return b;
  117:         }
  118:  
  119:         ////////////////////////////////////////////////////////////////////////////
  120:  
  121:         /// <summary>
  122:         /// 
  123:         /// </summary>
  124:         public static bool Delete(string id, out string result)
  125:         {
  126:             bool b;
  127:  
  128:             b = false;
  129:             result = string.Empty;
  130:  
  131:             using (var db = new Ia.Ftn.Cl.Model.Db())
  132:             {
  133:                 var v = (from s in db.Subscribers where s.Id == id select s).FirstOrDefault();
  134:  
  135:                 db.Subscribers.Remove(v);
  136:                 db.SaveChanges();
  137:  
  138:                 b = true;
  139:             }
  140:  
  141:             return b;
  142:         }
  143:  
  144:         ////////////////////////////////////////////////////////////////////////////
  145:         ////////////////////////////////////////////////////////////////////////////
  146:     }
  147:  
  148:     ////////////////////////////////////////////////////////////////////////////
  149:     ////////////////////////////////////////////////////////////////////////////
  150: }