Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
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;
   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:      /// Access 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 AccessController : ApiController
  30:      {
  31:          ////////////////////////////////////////////////////////////////////////////
  32:   
  33:          /// <summary>
  34:          /// 
  35:          /// </summary>
  36:          [DataContract(IsReference = true, Name = "apiResult")]
  37:          public class Result
  38:          {
  39:              [DataMember(Name = "isSuccessful")]
  40:              public bool IsSuccessful { get; set; }
  41:   
  42:              [DataMember(Name = "message")]
  43:              public string Message { get; set; }
  44:          }
  45:   
  46:          ////////////////////////////////////////////////////////////////////////////
  47:   
  48:          /// <summary>
  49:          /// Create an access
  50:          /// </summary>
  51:          [HttpGet]
  52:          public Result Create(string key, string accessName, string kuwaitNgnAreaSymbol, string block, string street, string premisesOld, string premisesNew, string odf, string paci, string note)
  53:          {
  54:              Ia.Cl.Model.Result result;
  55:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
  56:   
  57:              result = new Ia.Cl.Model.Result();
  58:   
  59:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
  60:   
  61:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Create, staffContact))
  62:              {
  63:                  Ia.Ngn.Cl.Model.Business.Access.Create(accessName, kuwaitNgnAreaSymbol, block, street, premisesOld, premisesNew, odf, paci, note, staffContact.UserId, out result);
  64:              }
  65:              else
  66:              {
  67:                  result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
  68:              }
  69:   
  70:              return new Result() { IsSuccessful = result.IsSuccessful, Message = result.Message };
  71:          }
  72:   
  73:          ////////////////////////////////////////////////////////////////////////////
  74:   
  75:          /// <summary>
  76:          /// Delete an access
  77:          /// </summary>
  78:          [HttpGet]
  79:          public Result Delete(string key, string accessName)
  80:          {
  81:              Ia.Cl.Model.Result result;
  82:              Ia.Ngn.Cl.Model.Business.Administration.StaffContact staffContact;
  83:   
  84:              result = new Ia.Cl.Model.Result();
  85:              staffContact = (from s in Ia.Ngn.Cl.Model.Data.Administration.StaffContactList where s.ApiKey == key select s).SingleOrDefault();
  86:   
  87:              if (Ia.Ngn.Cl.Model.Business.Authority.StaffContactCanCreateReadUpdateDeleteAccessList(Ia.Ngn.Cl.Model.Business.Authority.PersistentStorageFunction.Delete, staffContact))
  88:              {
  89:                  Ia.Ngn.Cl.Model.Business.Access.Delete(accessName, staffContact.UserId, out result);
  90:              }
  91:              else
  92:              {
  93:                  result.AddError("You are not authorized to modify this value (لست مخولاً بتعديل هذه القيمة). ");
  94:              }
  95:   
  96:              return new Result() { IsSuccessful = result.IsSuccessful, Message = result.Message };
  97:          }
  98:   
  99:          ////////////////////////////////////////////////////////////////////////////
 100:          ////////////////////////////////////////////////////////////////////////////
 101:      }
 102:  }