public async Task <JsonResult> OnPostDestroyPermission([DataSourceRequest] DataSourceRequest request, Permission permission)
        {
            try
            {
                await Task.Run(async() =>
                {
                    var permissionForDelete = _permissions.First(x => x.PermissionId == permission.PermissionId);
                    _permissions.Remove(permissionForDelete);

                    // Удаляем из кэша
                    var objForDelete = await _uow.Permissions.GetAsync(permission.PermissionId);
                    await _uow.Permissions.DeleteAsync(objForDelete);
                    await _uow.SaveChangesAsync();

                    // Производим удаление из mongodb
                    await _permissionsService.DeletePermissionAsync(objForDelete);
                });

                //await PopulateDropDownListsAsync();
            }
            catch (Exception e)
            {
                _logger.LogWarning($"--- OnPostDestroyPermission something wrong.\n\n Reason: {e.Message}");
                _logger.LogDebug(3000, e, "------------------------------------------------------");
            }

            return(new JsonResult(new[] { permission }.ToDataSourceResult(request, ModelState)));
        }
示例#2
0
        public async Task <IActionResult> RemovePermission(
            [Required] int id
            )
        {
            try
            {
                var responsePayload = await _permissionsService.DeletePermissionAsync(id);

                return(Ok(responsePayload));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { ex.Message }));
            }
        }
示例#3
0
        public async Task <IHttpActionResult> DeletePermission(string permId)
        {
            await _permissionsService.DeletePermissionAsync(permId);

            return(Ok());
        }