public async Task AddAsync(string name) { if (await _bucketRepository.GetAsync(name) != null) { throw new BucketAlreadyExistsException(); } await _bucketRepository.AddAsync(new Bucket(name)); }
public async Task AddAsync(string name) { var bucket = await _bucketRepository.GetAsync(name); if (bucket != null) { throw new CuboException("bucket_already_exists", $"Bucket '{name}' already exists."); } bucket = new Bucket(Guid.NewGuid(), name); await _bucketRepository.AddAsync(bucket); }
public static async Task <Bucket> GetOrFailAsync(this IBucketRepository repository, string name) { var bucket = await repository.GetAsync(name); if (bucket == null) { throw new CuboException("bucket_not_found", $"Bucket: '{name}' was not found."); } return(bucket); }
public static async Task <Bucket> GetAsyncOrFail(this IBucketRepository repository, string bucketName) { var bucket = await repository.GetAsync(bucketName); if (bucket == null) { throw new CuboException("bucket_not_found", $"Bucket {bucketName} could not be found."); } return(bucket); }
/*------------------------ FIELDS REGION ------------------------*/ /*------------------------ METHODS REGION ------------------------*/ public static async Task <Bucket> GetOrFailAsync(this IBucketRepository repository, string name) { Bucket bucket = await repository.GetAsync(name); if (bucket == null) { throw new BucketNotFoundException(); } return(bucket); }
public async Task AddAsync(string bucketName) { var bucket = await _repository.GetAsync(bucketName); if (bucket != null) { throw new CuboException("bucket_already_exists"); } bucket = new Bucket(Guid.NewGuid(), bucketName); await _repository.AddAsync(bucket); }