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

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), Internet 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:              else
  63:              {
  64:                  result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
  65:              }
  66:   
  67:              return new Result() { IsSuccessful = result.IsSuccessful, Message = result.Message };
  68:          }
  69:   
  70:          ////////////////////////////////////////////////////////////////////////////
  71:   
  72:          /// <summary>
  73:          /// Delete an access
  74:          /// </summary>
  75:          [HttpGet]
  76:          public Result Delete(string key, string accessName)
  77:          {
  78:              Ia.Cl.Model.Result result;
  79:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
  80:   
  81:              result = new Ia.Cl.Model.Result();
  82:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
  83:   
  84:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Delete, staffContact))
  85:              {
  86:                  Ia.Ngn.Cl.Model.Business.Access.Delete(accessName, staffContact.UserId, out result);
  87:              }
  88:              else
  89:              {
  90:                  result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
  91:              }
  92:   
  93:              return new Result() { IsSuccessful = result.IsSuccessful, Message = result.Message };
  94:          }
  95:   
  96:          ////////////////////////////////////////////////////////////////////////////
  97:          ////////////////////////////////////////////////////////////////////////////
  98:      }
  99:  }