public async Task AddAsync(string name)
        {
            if (await _bucketRepository.GetAsync(name) != null)
            {
                throw new BucketAlreadyExistsException();
            }

            await _bucketRepository.AddAsync(new Bucket(name));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 6
0
        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);
        }