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