コード例 #1
0
        public async Task <IActionResult> Delete(string id)
        {
            var download = await _downloads.GetByIdAsync(id);

            if (download == null)
            {
                return(NotFound(new ErrorResponse("The download does not exist.")));
            }

            var result = await _authorizationService.AuthorizeAsync(User, download, new DeleteOperationAuthorizationRequirement());

            if (!result.Succeeded)
            {
                return(Forbid(new ErrorResponse("Not authorized to delete download.")));
            }

            await _downloads.DeleteAsync(id);

            return(NoContent());
        }