コード例 #1
0
        /// <summary>
        /// Create a Permission on the basis of input ViewModel.Permission Set
        /// Input Permission must have RoleName as the string input.Role 
        /// and the Permission ID as input.ControllerId
        /// </summary>
        /// <param name="input"></param>
        public static void CreatePermission(ViewModel.Permission input)
        {
            try
               {
               //roleactions toCreate = input.toRoleAction();
               roleactions toCreate = new roleactions();
               if (!string.IsNullOrEmpty(input.Role))
               {
                   toCreate.Role = Parichay.Security.Helper.NHibernateProviderEntityHelper.GetRole(input.Role);
                   //toCreate.Users.Name = string.Empty;
               }
               else
               {
                   //toCreate.Role.Name = string.Empty;
                   toCreate.User = Parichay.Security.Helper.NHibernateProviderEntityHelper.GetUser(input.Users);
               }

               toCreate.Action = (Parichay.Security.Helper.NHibernateProviderEntityHelper.ConvertToListOf<actions>(Parichay.Security.Helper.NHibernateHelper.FindByNamedQuery("actions.byId", input.ControllerId, NHibernate.NHibernateUtil.Int32)))[0]; //(actions)Parichay.Security.Helper.NHibernateHelper.FindByNamedQuery("", new object[] { input.Controller, input.Action }, new NHibernate.Type.IType[] { NHibernate.NHibernateUtil.String, NHibernate.NHibernateUtil.String })[0];

               //toCreate.Action.ActionName = input.Action;
               //toCreate.Action.ControllerName = input.Controller;
               toCreate.PermissionType = input.PermissionType;

               Parichay.Security.Helper.NHibernateHelper.Save(toCreate);
               }
               catch (Exception ex)
               {
               throw (ex);
               }
        }
コード例 #2
0
        /// <summary>
        /// Deletes a particular Permission on the basis of Id
        /// </summary>
        /// <param name="Id">Permission Id to be deleted.</param>
        /// <returns></returns>
        public static int DeletePermission(int Id)
        {
            int result=0;
               try
               {
               roleactions ra = new roleactions();
               ra.Id = Id;
               Parichay.Security.Helper.NHibernateHelper.Delete(ra);

               }
               catch (Exception ex)
               {
               throw (ex);
               }
               return (result);
        }