Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Subscriber

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

Subscriber Entity Framework class for Next Generation Network (NGN) data model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Web;
   5:  using System.Web.Security;
   6:  using System.ComponentModel.DataAnnotations;
   7:  using System.ComponentModel.DataAnnotations.Schema;
   8:  using System.Text.RegularExpressions;
   9:  using System.Data.Entity;
  10:  using System.Xml.Linq;
  11:   
  12:  namespace Ia.Ngn.Cl.Model.Data.Nokia
  13:  {
  14:      ////////////////////////////////////////////////////////////////////////////
  15:   
  16:      /// <summary publish="true">
  17:      /// Subscriber Entity Framework class for Next Generation Network (NGN) data model.
  18:      /// </summary>
  19:      /// 
  20:      /// <remarks> 
  21:      /// Copyright � 2014-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  22:      ///
  23:      /// 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
  24:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  25:      ///
  26:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  27:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  28:      /// 
  29:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  30:      /// 
  31:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  32:      /// </remarks> 
  33:      public partial class Subscriber
  34:      {
  35:          /// <summary/>
  36:          public Subscriber() { }
  37:   
  38:          ////////////////////////////////////////////////////////////////////////////
  39:   
  40:          /// <summary>
  41:          /// 
  42:          /// </summary>
  43:          public static bool Create(Ia.Ngn.Cl.Model.Nokia.Subscriber subscriber, out string result)
  44:          {
  45:              bool b;
  46:   
  47:              b = false;
  48:              result = "";
  49:   
  50:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  51:              {
  52:                  subscriber.Created = subscriber.Updated = DateTime.UtcNow.AddHours(3);
  53:   
  54:                  db.Subscribers.Add(subscriber);
  55:                  db.SaveChanges();
  56:   
  57:                  b = true;
  58:              }
  59:   
  60:              return b;
  61:          }
  62:   
  63:          ////////////////////////////////////////////////////////////////////////////
  64:   
  65:          /// <summary>
  66:          /// 
  67:          /// </summary>
  68:          public static Ia.Ngn.Cl.Model.Nokia.Subscriber Read(string id)
  69:          {
  70:              Ia.Ngn.Cl.Model.Nokia.Subscriber subscriber;
  71:   
  72:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  73:              {
  74:                  subscriber = (from s in db.Subscribers where s.Id == id select s).SingleOrDefault();
  75:              }
  76:   
  77:              return subscriber;
  78:          }
  79:   
  80:          ////////////////////////////////////////////////////////////////////////////
  81:   
  82:          /// <summary>
  83:          /// 
  84:          /// </summary>
  85:          public static List<Ia.Ngn.Cl.Model.Nokia.Subscriber> ReadList()
  86:          {
  87:              List<Ia.Ngn.Cl.Model.Nokia.Subscriber> subscriberList;
  88:   
  89:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  90:              {
  91:                  subscriberList = (from s in db.Subscribers select s).ToList();
  92:              }
  93:   
  94:              return subscriberList;
  95:          }
  96:   
  97:          ////////////////////////////////////////////////////////////////////////////
  98:   
  99:          /// <summary>
 100:          /// 
 101:          /// </summary>
 102:          public static bool Update(Ia.Ngn.Cl.Model.Nokia.Subscriber subscriber, out string result)
 103:          {
 104:              bool b;
 105:   
 106:              b = false;
 107:              result = "";
 108:   
 109:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 110:              {
 111:                  subscriber = (from s in db.Subscribers where s.Id == subscriber.Id select s).SingleOrDefault();
 112:   
 113:                  subscriber.Updated = DateTime.UtcNow.AddHours(3);
 114:   
 115:                  db.Subscribers.Attach(subscriber);
 116:   
 117:                  db.Entry(subscriber).State = System.Data.Entity.EntityState.Modified;
 118:                  db.SaveChanges();
 119:   
 120:                  b = true;
 121:              }
 122:   
 123:              return b;
 124:          }
 125:   
 126:          ////////////////////////////////////////////////////////////////////////////
 127:   
 128:          /// <summary>
 129:          /// 
 130:          /// </summary>
 131:          public static bool Delete(string id, out string result)
 132:          {
 133:              bool b;
 134:   
 135:              b = false;
 136:              result = "";
 137:   
 138:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 139:              {
 140:                  var v = (from s in db.Subscribers where s.Id == id select s).FirstOrDefault();
 141:   
 142:                  db.Subscribers.Remove(v);
 143:                  db.SaveChanges();
 144:   
 145:                  b = true;
 146:              }
 147:   
 148:              return b;
 149:          }
 150:   
 151:          ////////////////////////////////////////////////////////////////////////////
 152:          ////////////////////////////////////////////////////////////////////////////
 153:      }
 154:   
 155:      ////////////////////////////////////////////////////////////////////////////
 156:      ////////////////////////////////////////////////////////////////////////////
 157:  }