Esempio n. 1
0
        public async Task <JsonResult> DeleteBucket([FromForm] DeleteBucketAddressModel model)
        {
            var appid  = _tokenManager.ValidateAccessToken(model.AccessToken);
            var bucket = await _dbContext.Bucket.FindAsync(model.BucketId);

            if (bucket.BelongingAppId != appid)
            {
                return(this.Protocol(ErrorType.Unauthorized, "The bucket you try to delete is not your app's bucket!"));
            }
            _dbContext.Bucket.Remove(bucket);
            _dbContext.OSSFile.RemoveRange(_dbContext.OSSFile.Where(t => t.BucketId == bucket.BucketId));
            await _dbContext.SaveChangesAsync();

            return(this.Protocol(ErrorType.Success, "Successfully deleted your bucket!"));
        }
Esempio n. 2
0
        public async Task <JsonResult> DeleteBucket([FromForm] DeleteBucketAddressModel model)
        {
            var app = await APIService.ValidateAccessTokenAsync(model.AccessToken);

            var bucket = await _dbContext.Bucket.FindAsync(model.BucketId);

            if (bucket.BelongingAppId != app.AppId)
            {
                return(Json(new AiurProtocal {
                    code = ErrorType.Unauthorized, message = "The bucket you try to delete is not your app's bucket!"
                }));
            }
            _dbContext.Bucket.Remove(bucket);
            _dbContext.OSSFile.RemoveRange(_dbContext.OSSFile.Where(t => t.BucketId == bucket.BucketId));
            await _dbContext.SaveChangesAsync();

            return(Json(new AiurProtocal {
                code = ErrorType.Success, message = "Successfully deleted your bucket!"
            }));
        }