شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » ServiceExemption

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

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

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:   
   5:  namespace Ia.Ngn.Cl.Model.Data
   6:  {
   7:      ////////////////////////////////////////////////////////////////////////////
   8:   
   9:      /// <summary publish="true">
  10:      /// ServiceExemption Framework class for Next Generation Network (NGN) data model.
  11:      /// </summary>
  12:      /// 
  13:      /// <remarks> 
  14:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet 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 partial class ServiceExemption
  27:      {
  28:          /// <summary/>
  29:          public ServiceExemption() { }
  30:   
  31:          ////////////////////////////////////////////////////////////////////////////
  32:   
  33:          /// <summary>
  34:          ///
  35:          /// </summary>
  36:          public static string Create(Ia.Ngn.Cl.Model.ServiceExemption serviceExemption, out string result)
  37:          {
  38:              string id;
  39:   
  40:              id = string.Empty;
  41:              result = string.Empty;
  42:   
  43:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  44:              {
  45:                  serviceExemption.Created = serviceExemption.Updated = DateTime.UtcNow.AddHours(3);
  46:   
  47:                  db.ServiceExemptions.Add(serviceExemption);
  48:                  db.SaveChanges();
  49:   
  50:                  id = serviceExemption.Service;
  51:              }
  52:   
  53:              return id;
  54:          }
  55:   
  56:          ////////////////////////////////////////////////////////////////////////////
  57:   
  58:          /// <summary>
  59:          ///
  60:          /// </summary>
  61:          public static Ia.Ngn.Cl.Model.ServiceExemption Read(string id)
  62:          {
  63:              Ia.Ngn.Cl.Model.ServiceExemption serviceExemption;
  64:   
  65:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  66:              {
  67:                  serviceExemption = (from s in db.ServiceExemptions where s.Id == id select s).SingleOrDefault();
  68:              }
  69:   
  70:              return serviceExemption;
  71:          }
  72:   
  73:          ////////////////////////////////////////////////////////////////////////////
  74:   
  75:          /// <summary>
  76:          ///
  77:          /// </summary>
  78:          public static List<Ia.Ngn.Cl.Model.ServiceExemption> ReadList()
  79:          {
  80:              List<Ia.Ngn.Cl.Model.ServiceExemption> serviceExemptionList;
  81:   
  82:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  83:              {
  84:                  serviceExemptionList = (from s in db.ServiceExemptions select s).ToList();
  85:              }
  86:   
  87:              return serviceExemptionList;
  88:          }
  89:   
  90:          ////////////////////////////////////////////////////////////////////////////
  91:   
  92:          /// <summary>
  93:          ///
  94:          /// </summary>
  95:          public static List<string> ReadServiceIdList
  96:          {
  97:              get
  98:              {
  99:                  List<string> serviceExemptionList;
 100:   
 101:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 102:                  {
 103:                      serviceExemptionList = (from s in db.ServiceExemptions select s.Id).ToList();
 104:                  }
 105:   
 106:                  return serviceExemptionList;
 107:              }
 108:          }
 109:   
 110:          ////////////////////////////////////////////////////////////////////////////
 111:   
 112:          /// <summary>
 113:          ///
 114:          /// </summary>
 115:          public static List<string> ReadServiceList
 116:          {
 117:              get
 118:              {
 119:                  List<string> serviceExemptionList;
 120:   
 121:                  using (var db = new Ia.Ngn.Cl.Model.Ngn())
 122:                  {
 123:                      serviceExemptionList = (from s in db.ServiceExemptions select s.Service).ToList();
 124:                  }
 125:   
 126:                  return serviceExemptionList;
 127:              }
 128:          }
 129:   
 130:          ////////////////////////////////////////////////////////////////////////////
 131:   
 132:          /// <summary>
 133:          ///
 134:          /// </summary>
 135:          public static bool Update(Ia.Ngn.Cl.Model.ServiceExemption updatedServiceExemption, out string result)
 136:          {
 137:              bool b;
 138:              Ia.Ngn.Cl.Model.ServiceExemption serviceExemption;
 139:   
 140:              b = false;
 141:              result = string.Empty;
 142:   
 143:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 144:              {
 145:                  serviceExemption = (from se in db.ServiceExemptions where se.Id == updatedServiceExemption.Id select se).SingleOrDefault();
 146:   
 147:                  if (serviceExemption.Update(updatedServiceExemption))
 148:                  {
 149:                      db.ServiceExemptions.Attach(serviceExemption);
 150:                      db.Entry(serviceExemption).State = System.Data.Entity.EntityState.Modified;
 151:                  }
 152:   
 153:                  db.SaveChanges();
 154:   
 155:                  b = true;
 156:              }
 157:   
 158:              return b;
 159:          }
 160:   
 161:          ////////////////////////////////////////////////////////////////////////////
 162:   
 163:          /// <summary>
 164:          ///
 165:          /// </summary>
 166:          public static bool Delete(string id)
 167:          {
 168:              bool b;
 169:   
 170:              b = false;
 171:   
 172:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 173:              {
 174:                  var v = (from s in db.ServiceExemptions where s.Id == id select s).FirstOrDefault();
 175:   
 176:                  db.ServiceExemptions.Remove(v);
 177:                  db.SaveChanges();
 178:   
 179:                  b = true;
 180:              }
 181:   
 182:              return b;
 183:          }
 184:   
 185:          ////////////////////////////////////////////////////////////////////////////
 186:          ////////////////////////////////////////////////////////////////////////////
 187:      }
 188:   
 189:      ////////////////////////////////////////////////////////////////////////////
 190:      ////////////////////////////////////////////////////////////////////////////
 191:  }