Beispiel #1
0
        /// <summary>
        /// Grants a permission to a user given the model.
        /// </summary>
        /// <param name="deletedPermission">The model containing the deleted permission.</param>
        /// <returns>The task.</returns>
        public async Task DeletePermissionAsync(IDeletedPermissionBindingModel deletedPermission)
        {
            var grantorUserId = GetGrantorPrincipalId();
            var permission    = deletedPermission.ToDeletedPermission(grantorUserId);

            throwIfGrantorAndGranteePrincipalIdEqual(permission.GranteePrincipalId, grantorUserId);
            await principalService.DeletePermissionAsync(permission);

            await ClearUserCacheAsync(permission.GranteePrincipalId);
        }
Beispiel #2
0
        /// <summary>
        /// Handles the given model from a client via the given controller.
        /// </summary>
        /// <param name="model">The permission model.</param>
        /// <param name="controller">The controller that is handling the client request.</param>
        /// <returns>The result the controller should return.</returns>
        public async Task <IHttpActionResult> HandleDeletedPermissionBindingModelAsync(IDeletedPermissionBindingModel model, ApiController controller)
        {
            if (controller.ModelState.IsValid)
            {
                await DeletePermissionAsync(model);
                await SaveChangesAsync();

                return(new OkResult(controller));
            }
            else
            {
                return(new InvalidModelStateResult(controller.ModelState, controller));
            }
        }