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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » ServiceSuspensionController

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

Service Suspension API Controller class of Next Generation Network'a (NGN's) model.

   1:  using System;
   2:  using System.Linq;
   3:  using System.Runtime.Serialization;
   4:  using System.Web.Http;
   5:   
   6:  namespace Ia.Ngn.Cl.Model.Api.Controller
   7:  {
   8:      ////////////////////////////////////////////////////////////////////////////
   9:   
  10:      /// <summary publish="true">
  11:      /// Service Suspension API Controller class of Next Generation Network'a (NGN's) model.
  12:      /// </summary>
  13:      /// 
  14:      /// <remarks> 
  15:      /// Copyright © 2006-2019 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  16:      ///
  17:      /// 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
  18:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  19:      ///
  20:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  21:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  22:      /// 
  23:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  24:      /// 
  25:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  26:      /// </remarks> 
  27:      public class ServiceSuspensionController : ApiController
  28:      {
  29:          ////////////////////////////////////////////////////////////////////////////
  30:   
  31:          /// <summary>
  32:          /// 
  33:          /// </summary>
  34:          [DataContract(IsReference = true, Name = "apiAdministrationServiceSuspensionActivateSuspendResult")]
  35:          public class ServiceSuspensionActivateSuspendResult
  36:          {
  37:              [DataMember(Name = "number")]
  38:              public string Number { get; set; }
  39:   
  40:              [DataMember(Name = "isSuccessful")]
  41:              public bool IsSuccessful { get; set; }
  42:   
  43:              [DataMember(Name = "message")]
  44:              public string Message { get; set; }
  45:          }
  46:   
  47:          ////////////////////////////////////////////////////////////////////////////
  48:   
  49:          /// <summary>
  50:          /// 
  51:          /// </summary>
  52:          [DataContract(IsReference = true, Name = "apiAdministrationServiceSuspensionReadResult")]
  53:          public class ServiceSuspensionReadResult
  54:          {
  55:              [DataMember(Name = "number")]
  56:              public string Number { get; set; }
  57:   
  58:              [DataMember(Name = "isSuccessful")]
  59:              public bool IsSuccessful { get; set; }
  60:   
  61:              [DataMember(Name = "isSuspended")]
  62:              public bool IsSuspended { get; set; }
  63:   
  64:              [DataMember(Name = "serviceLastUpdated")]
  65:              public DateTime ServiceLastUpdated { get; set; }
  66:   
  67:              [DataMember(Name = "message")]
  68:              public string Message { get; set; }
  69:          }
  70:   
  71:          ////////////////////////////////////////////////////////////////////////////
  72:   
  73:          /// <summary>
  74:          /// Activate a service number
  75:          /// </summary>
  76:          /// <param name="key">Private access key</param>
  77:          /// <param name="service">Service number to activate</param>
  78:          [HttpGet]
  79:          public ServiceSuspensionActivateSuspendResult Activate(string key, string service)
  80:          {
  81:              Ia.Cl.Model.Result result;
  82:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
  83:   
  84:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
  85:   
  86:              Ia.Ngn.Cl.Model.Business.ServiceRequestService.UpdateServiceSuspension(service, false, staffContact, out result);
  87:   
  88:              Ia.Ngn.Cl.Model.Data.Administration.ServiceSuspensionFlagCounter++;
  89:   
  90:              return new ServiceSuspensionActivateSuspendResult() { Number = service, IsSuccessful = result.IsSuccessful, Message = result.Message };
  91:          }
  92:   
  93:          ////////////////////////////////////////////////////////////////////////////
  94:   
  95:          /// <summary>
  96:          /// Suspend a service number
  97:          /// </summary>
  98:          /// <param name="key">Private access key</param>
  99:          /// <param name="service">Service number to suspend</param>
 100:          [HttpGet]
 101:          public ServiceSuspensionActivateSuspendResult Suspend(string key, string service)
 102:          {
 103:              Ia.Cl.Model.Result result;
 104:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
 105:   
 106:              result = new Ia.Cl.Model.Result();
 107:   
 108:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
 109:   
 110:              Ia.Ngn.Cl.Model.Business.ServiceRequestService.UpdateServiceSuspension(service, true, staffContact, out result);
 111:   
 112:              Ia.Ngn.Cl.Model.Data.Administration.ServiceSuspensionFlagCounter++;
 113:   
 114:              return new ServiceSuspensionActivateSuspendResult() { Number = service, IsSuccessful = result.IsSuccessful, Message = result.Message };
 115:          }
 116:   
 117:          ////////////////////////////////////////////////////////////////////////////
 118:   
 119:          /// <summary>
 120:          /// Read the status of a service number. The output will indicate the update date in which data was last read and updated from the system.
 121:          /// </summary>
 122:          /// <param name="key">Private access key</param>
 123:          /// <param name="service">Service number to suspend</param>
 124:          [HttpGet]
 125:          public ServiceSuspensionReadResult Read(string key, string service)
 126:          {
 127:              bool isSuspended;
 128:              DateTime serviceLastUpdated;
 129:              Ia.Cl.Model.Result result;
 130:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
 131:   
 132:              result = new Ia.Cl.Model.Result();
 133:   
 134:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
 135:   
 136:              Ia.Ngn.Cl.Model.Business.ServiceRequestService.ReadServiceSuspension(service, staffContact, key, out isSuspended, out serviceLastUpdated, out result);
 137:   
 138:              return new ServiceSuspensionReadResult() { Number = service, IsSuccessful = result.IsSuccessful, IsSuspended = isSuspended, ServiceLastUpdated = serviceLastUpdated, Message = result.Message };
 139:          }
 140:   
 141:          ////////////////////////////////////////////////////////////////////////////
 142:   
 143:          /// <summary>
 144:          /// Increment the flag counter value of service suspensions to indicate the existance of an order
 145:          /// </summary>
 146:          [HttpGet]
 147:          public int FlagCounterIncrement()
 148:          {
 149:              Ia.Cl.Model.Result result;
 150:   
 151:              result = new Ia.Cl.Model.Result();
 152:   
 153:              return ++Ia.Ngn.Cl.Model.Data.Administration.ServiceSuspensionFlagCounter;
 154:          }
 155:   
 156:          ////////////////////////////////////////////////////////////////////////////
 157:   
 158:          /// <summary>
 159:          /// Decrement the flag counter value of service suspensions to indicate the existance of an order
 160:          /// </summary>
 161:          [HttpGet]
 162:          public int FlagCounterDecrement()
 163:          {
 164:              Ia.Cl.Model.Result result;
 165:   
 166:              result = new Ia.Cl.Model.Result();
 167:   
 168:              return --Ia.Ngn.Cl.Model.Data.Administration.ServiceSuspensionFlagCounter;
 169:          }
 170:   
 171:          ////////////////////////////////////////////////////////////////////////////
 172:   
 173:          /// <summary>
 174:          /// Read the flag counter of service suspensions 
 175:          /// </summary>
 176:          [HttpGet]
 177:          public int FlagCounterRead()
 178:          {
 179:              Ia.Cl.Model.Result result;
 180:   
 181:              result = new Ia.Cl.Model.Result();
 182:   
 183:              return Ia.Ngn.Cl.Model.Data.Administration.ServiceSuspensionFlagCounter;
 184:          }
 185:   
 186:          ////////////////////////////////////////////////////////////////////////////
 187:          ////////////////////////////////////////////////////////////////////////////
 188:      }
 189:  }