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

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » AccessController

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

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

   1:  using System.Linq;
   2:  using System.Runtime.Serialization;
   3:  using System.Web.Http;
   4:   
   5:  namespace Ia.Ngn.Cl.Model.Api.Controller
   6:  {
   7:      ////////////////////////////////////////////////////////////////////////////
   8:   
   9:      /// <summary publish="true">
  10:      /// Access API Controller class of Next Generation Network'a (NGN's) model.
  11:      /// </summary>
  12:      /// 
  13:      /// <remarks> 
  14:      /// Copyright © 2006-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
  15:      ///
  16:      /// 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
  17:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  18:      ///
  19:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  20:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  21:      /// 
  22:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  23:      /// 
  24:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  25:      /// </remarks> 
  26:      public class AccessController : ApiController
  27:      {
  28:          ////////////////////////////////////////////////////////////////////////////
  29:   
  30:          /// <summary>
  31:          /// 
  32:          /// </summary>
  33:          [DataContract(IsReference = true, Name = "apiResult")]
  34:          public class Result
  35:          {
  36:              [DataMember(Name = "isSuccessful")]
  37:              public bool IsSuccessful { get; set; }
  38:   
  39:              [DataMember(Name = "message")]
  40:              public string Message { get; set; }
  41:          }
  42:   
  43:          ////////////////////////////////////////////////////////////////////////////
  44:   
  45:          /// <summary>
  46:          /// Create an access
  47:          /// </summary>
  48:          [HttpGet]
  49:          public Result Create(string key, string accessName, string kuwaitNgnAreaSymbol, string block, string street, string premisesOld, string premisesNew, string odf, string paci, string note)
  50:          {
  51:              Ia.Cl.Model.Result result;
  52:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
  53:   
  54:              result = new Ia.Cl.Model.Result();
  55:   
  56:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
  57:   
  58:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
  59:              {
  60:                  Ia.Ngn.Cl.Model.Business.Access.Create(accessName, kuwaitNgnAreaSymbol, block, street, premisesOld, premisesNew, odf, paci, note, staffContact.UserId, out result);
  61:   
  62:                  Ia.Ngn.Cl.Model.Data.Msmq.AccessNameQueue.ProvisionAccessQueue.Enqueue(accessName);
  63:              }
  64:              else
  65:              {
  66:                  result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
  67:              }
  68:   
  69:              return new Result() { IsSuccessful = result.IsSuccessful, Message = result.Message };
  70:          }
  71:   
  72:          ////////////////////////////////////////////////////////////////////////////
  73:   
  74:          /// <summary>
  75:          /// Delete an access
  76:          /// </summary>
  77:          [HttpGet]
  78:          public Result Delete(string key, string accessName)
  79:          {
  80:              Ia.Cl.Model.Result result;
  81:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
  82:   
  83:              result = new Ia.Cl.Model.Result();
  84:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
  85:   
  86:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Delete, staffContact))
  87:              {
  88:                  Ia.Ngn.Cl.Model.Business.Access.Delete(accessName, staffContact.UserId, out result);
  89:              }
  90:              else
  91:              {
  92:                  result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
  93:              }
  94:   
  95:              return new Result() { IsSuccessful = result.IsSuccessful, Message = result.Message };
  96:          }
  97:   
  98:          ////////////////////////////////////////////////////////////////////////////
  99:          ////////////////////////////////////////////////////////////////////////////
 100:      }
 101:  }