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

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

SubParty support class for Nokia's 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:   
  11:  namespace Ia.Ngn.Cl.Model.Data.Nokia
  12:  {
  13:      ////////////////////////////////////////////////////////////////////////////
  14:   
  15:      /// <summary publish="true">
  16:      /// SubParty support class for Nokia's Next Generation Network (NGN) data model.
  17:      /// </summary>
  18:      /// 
  19:      /// <remarks> 
  20:      /// Copyright � 2014-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 SubParty
  33:      {
  34:          public SubParty() { }
  35:   
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          ///
  40:          /// </summary>
  41:          public static bool Create(Ia.Ngn.Cl.Model.Nokia.SubParty subParty, out string result)
  42:          {
  43:              bool b;
  44:   
  45:              b = false;
  46:              result = "";
  47:   
  48:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  49:              {
  50:                  subParty.Created = subParty.Updated = DateTime.UtcNow.AddHours(3);
  51:   
  52:                  db.SubParties.Add(subParty);
  53:                  db.SaveChanges();
  54:   
  55:                  b = true;
  56:              }
  57:   
  58:              return b;
  59:          }
  60:   
  61:          ////////////////////////////////////////////////////////////////////////////
  62:   
  63:          /// <summary>
  64:          ///
  65:          /// </summary>
  66:          public static Ia.Ngn.Cl.Model.Nokia.SubParty Read(string id)
  67:          {
  68:              Ia.Ngn.Cl.Model.Nokia.SubParty subParty;
  69:   
  70:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  71:              {
  72:                  subParty = (from sp in db.SubParties where sp.Id == id select sp).SingleOrDefault();
  73:              }
  74:   
  75:              return subParty;
  76:          }
  77:   
  78:          ////////////////////////////////////////////////////////////////////////////
  79:   
  80:          /// <summary>
  81:          ///
  82:          /// </summary>
  83:          public static List<Ia.Ngn.Cl.Model.Nokia.SubParty> ReadList()
  84:          {
  85:              List<Ia.Ngn.Cl.Model.Nokia.SubParty> subPartyList;
  86:   
  87:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
  88:              {
  89:                  subPartyList = (from sp in db.SubParties select sp).ToList();
  90:              }
  91:   
  92:              return subPartyList;
  93:          }
  94:   
  95:          ////////////////////////////////////////////////////////////////////////////
  96:   
  97:          /// <summary>
  98:          ///
  99:          /// </summary>
 100:          public static bool Update(Ia.Ngn.Cl.Model.Nokia.SubParty subParty, out string result)
 101:          {
 102:              bool b;
 103:   
 104:              b = false;
 105:              result = "";
 106:   
 107:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 108:              {
 109:                  subParty = (from sp in db.SubParties where sp.Id == subParty.Id select sp).SingleOrDefault();
 110:   
 111:                  subParty.Updated = DateTime.UtcNow.AddHours(3);
 112:   
 113:                  db.SubParties.Attach(subParty);
 114:   
 115:                  db.Entry(subParty).State = System.Data.Entity.EntityState.Modified;
 116:                  db.SaveChanges();
 117:   
 118:                  b = true;
 119:              }
 120:   
 121:              return b;
 122:          }
 123:   
 124:          ////////////////////////////////////////////////////////////////////////////
 125:   
 126:          /// <summary>
 127:          ///
 128:          /// </summary>
 129:          public static bool Delete(string id, out string result)
 130:          {
 131:              bool b;
 132:   
 133:              b = false;
 134:              result = "";
 135:   
 136:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 137:              {
 138:                  var v = (from sp in db.SubParties where sp.Id == id select sp).FirstOrDefault();
 139:   
 140:                  db.SubParties.Remove(v);
 141:                  db.SaveChanges();
 142:   
 143:                  b = true;
 144:              }
 145:   
 146:              return b;
 147:          }
 148:   
 149:          ////////////////////////////////////////////////////////////////////////////
 150:   
 151:          /// <summary>
 152:          /// Read list of service PBX numbers that have Category == "SERVICEBUNDLE2"
 153:          /// </summary>
 154:          public static List<string> ServicePbxList()
 155:          {
 156:              List<string> l1, l2;
 157:   
 158:              l1 = l2 = null;
 159:   
 160:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 161:              {
 162:                  l1 = (from sp in db.SubParties where sp.Category == "SERVICEBUNDLE2" select sp.PartyId).ToList();
 163:   
 164:                  if (l1.Count > 0)
 165:                  {
 166:                      l2 = new List<string>(l1.Count);
 167:   
 168:                      foreach (string s in l1) l2.Add(Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(s));
 169:                  }
 170:              }
 171:   
 172:              return l2;
 173:          }
 174:   
 175:          ////////////////////////////////////////////////////////////////////////////
 176:   
 177:          /// <summary>
 178:          /// Read list of service Id PBX numbers that have Category == "SERVICEBUNDLE2"
 179:          /// </summary>
 180:          public static List<string> ServiceIdPbxList()
 181:          {
 182:              int serviceType;
 183:              string service, serviceId;
 184:              List<string> l1, l2;
 185:   
 186:              serviceType = 1;
 187:              l1 = l2 = null;
 188:   
 189:              using (var db = new Ia.Ngn.Cl.Model.Ngn())
 190:              {
 191:                  l1 = (from sp in db.SubParties where sp.Category == "SERVICEBUNDLE2" select sp.PartyId).ToList();
 192:   
 193:                  if (l1.Count > 0)
 194:                  {
 195:                      l2 = new List<string>(l1.Count);
 196:   
 197:                      foreach (string u in l1)
 198:                      {
 199:                          service = Ia.Ngn.Cl.Model.Business.NumberFormatConverter.Service(u);
 200:   
 201:                          serviceId = Ia.Ngn.Cl.Model.Business.Service2.ServiceId(service, serviceType);
 202:   
 203:                          l2.Add(serviceId);
 204:                      }
 205:                  }
 206:              }
 207:   
 208:              return l2;
 209:          }
 210:   
 211:          ////////////////////////////////////////////////////////////////////////////
 212:          ////////////////////////////////////////////////////////////////////////////
 213:      }
 214:   
 215:      ////////////////////////////////////////////////////////////////////////////
 216:      ////////////////////////////////////////////////////////////////////////////
 217:  }