コード例 #1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreatePermissionResponse response = new CreatePermissionResponse();


            return(response);
        }
コード例 #2
0
        public CreatePermissionResponse CreatePermission(CreatePermissionRequest request)
        {
            IPermissionService       permissionService = IoC.Container.Resolve <IPermissionService>();
            CreatePermissionResponse per = permissionService.Create(request);

            return(per);
        }
コード例 #3
0
        public void Security_Permission_CreatePermission_ShouldBeSuccess_WithValidRequest()
        {
            string name = "Name of Permission" + Guid.NewGuid();
            string key  = "Key of Permission" + Guid.NewGuid();
            string desc = "Desc of Permission";
            CreatePermissionResponse permission = this.CreatePermissionItem(name, key, desc);

            Assert.IsNotNull(permission);
        }
コード例 #4
0
        public JsonResult Create(PermissionDetailView vm)
        {
            CreatePermissionRequest request = new CreatePermissionRequest();

            request.PermissionName        = vm.PermissionName;
            request.PermissionDescription = vm.PermissionDescription;
            request.ControllerName        = vm.ControllerName;
            request.ActionName            = vm.ActionName;
            request.IsAnonymous           = vm.IsAnonymous;
            request.IsDefaultAllow        = vm.IsDefaultAllow;
            CreatePermissionResponse response = _permissionService.CreatePermission(request);

            return(Json(response));
        }
コード例 #5
0
        protected override void OnInit()
        {
            base.OnInit();
            string name = "Name of Permission" + Guid.NewGuid();
            string key  = "Key of Permission" + Guid.NewGuid();
            string desc = "Desc of Permission";

            this.permission = this.CreatePermissionItem(name, key, desc);

            name             = "Duplicated Name" + Guid.NewGuid();
            key              = "Duplicated key" + Guid.NewGuid();
            desc             = "Desc of Permission";
            this.permission1 = this.CreatePermissionItem(name, key, desc);
        }
コード例 #6
0
        public void Security_Permission_DeletePermission_ShouldBeSuccess_WithValidRequest()
        {
            string name = "Name of Permission" + Guid.NewGuid();
            string key  = "Key of Permission" + Guid.NewGuid();
            string desc = "Desc of Permission";
            CreatePermissionResponse permission = this.CreatePermissionItem(name, key, desc);

            this.DeletePermission(permission.Id);

            IPermissionService service = IoC.Container.Resolve <IPermissionService>();

            App.Service.Security.Permission.GetPermissionResponse deletedPermisison = service.GetPermission(permission.Id);
            Assert.IsNull(deletedPermisison);
        }
コード例 #7
0
        public async Task <CreatePermissionResponse> CreatePermission(CreatePermissionRequest request)
        {
            var sessionUser = await _sessionManager.GetUser();

            var response = new CreatePermissionResponse();

            var permissions = await _cache.Permissions();

            var permission = permissions.FirstOrDefault(c => c.Key == request.Key);

            if (permission != null)
            {
                response.Notifications.AddError($"A permission already exists with the key {request.Key}");
                return(response);
            }

            int id;

            using (var uow = _uowFactory.GetUnitOfWork())
            {
                id = await uow.UserRepo.CreatePermission(new Repositories.DatabaseRepos.UserRepo.Models.CreatePermissionRequest()
                {
                    Key         = request.Key,
                    Description = request.Description,
                    Group_Name  = request.GroupName,
                    Name        = request.Name,
                    Created_By  = sessionUser.Id
                });

                uow.Commit();
            }

            _cache.Remove(CacheConstants.Permissions);

            await _sessionManager.WriteSessionLogEvent(new Models.ManagerModels.Session.CreateSessionLogEventRequest()
            {
                EventKey = SessionEventKeys.PermissionCreated,
                Info     = new Dictionary <string, string>()
                {
                    { "Key", request.Key }
                }
            });

            response.Notifications.Add($"Permission '{request.Key}' has been created", NotificationTypeEnum.Success);
            return(response);
        }
コード例 #8
0
        public CreatePermissionResponse CreatePermission(CreatePermissionRequest request)
        {
            CreatePermissionResponse response = new CreatePermissionResponse();
            Permission permission             = new Permission();

            permission.PermissionName        = request.PermissionName;
            permission.PermissionDescription = request.PermissionDescription;
            permission.ControllerName        = request.ControllerName;
            permission.ActionName            = request.ActionName;
            permission.IsAnonymous           = request.IsAnonymous;
            permission.IsDefaultAllow        = request.IsDefaultAllow;
            permission.Roles = request.Roles.ConvertToRoles();
            permission.Users = request.Users.ConvertToUsers();

            if (permission.GetBrokenRules().Count() > 0)
            {
                response.Errors = permission.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _permissionRepository.Add(permission);
                    _uow.Commit();
                    response.Errors = new List <BusinessRule>();
                } catch (Exception ex)
                {
                    List <BusinessRule> errors = new List <BusinessRule>();
                    do
                    {
                        errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message));
                        ex = ex.InnerException;
                    } while (ex != null);

                    response.Errors = errors;
                }
            }

            return(response);
        }
コード例 #9
0
 public UpdatePermission() : base(@"api/permissions/{0}")
 {
     this.createdPermissionResponse = this.CreateNewPermission();
 }