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

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), Integrated 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:          [Route("api/administration/service-suspension/activate/{key}/{number}")]
  80:          public ServiceSuspensionActivateSuspendResult Activate(string key, string service)
  81:          {
  82:              Ia.Cl.Model.Result result;
  83:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
  84:   
  85:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
  86:   
  87:              Ia.Ngn.Cl.Model.Business.ServiceRequestService.UpdateServiceSuspension(service, false, staffContact, out result);
  88:   
  89:              Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.ServiceSuspensionQueue.Enqueue(service);
  90:   
  91:              return new ServiceSuspensionActivateSuspendResult() { Number = service, IsSuccessful = result.IsSuccessful, Message = result.Message };
  92:          }
  93:   
  94:          ////////////////////////////////////////////////////////////////////////////
  95:   
  96:          /// <summary>
  97:          /// Suspend a service number
  98:          /// </summary>
  99:          /// <param name="key">Private access key</param>
 100:          /// <param name="service">Service number to suspend</param>
 101:          [HttpGet]
 102:          [Route("api/administration/service-suspension/suspend/{key}/{number}")]
 103:          public ServiceSuspensionActivateSuspendResult Suspend(string key, string service)
 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(service, true, staffContact, out result);
 113:   
 114:              Ia.Ngn.Cl.Model.Data.Msmq.ServiceQueue.ServiceSuspensionQueue.Enqueue(service);
 115:   
 116:              return new ServiceSuspensionActivateSuspendResult() { Number = service, 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="service">Service number to suspend</param>
 126:          [HttpGet]
 127:          [Route("api/administration/service-suspension/read/{key}/{number}")]
 128:          public ServiceSuspensionReadResult Read(string key, string service)
 129:          {
 130:              bool isSuspended;
 131:              DateTime serviceLastUpdated;
 132:              Ia.Cl.Model.Result result;
 133:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
 134:   
 135:              result = new Ia.Cl.Model.Result();
 136:   
 137:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
 138:   
 139:              Ia.Ngn.Cl.Model.Business.ServiceRequestService.ReadServiceSuspension(service, staffContact, key, out isSuspended, out serviceLastUpdated, out result);
 140:   
 141:              return new ServiceSuspensionReadResult() { Number = service, IsSuccessful = result.IsSuccessful, IsSuspended = isSuspended, ServiceLastUpdated = serviceLastUpdated, Message = result.Message };
 142:          }
 143:   
 144:          ////////////////////////////////////////////////////////////////////////////
 145:          ////////////////////////////////////////////////////////////////////////////
 146:      }
 147:  }