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