Пример #1
0
        public async Task <Result <BikeResponse> > AddBikeAsync(AddBikeCommand request)
        {
            // validation if bike is being added to the specific HomeBase ...
            if (request.HomeBaseId is not null)
            {
                if (!_homeBaseService.CheckIfExistsAsync(request.HomeBaseId))
                {
                    return(new Result <BikeResponse>(new BadRequestException(Error.HomeBaseNotFound)));
                }

                if (!await _homeBaseService.CheckIfFreeSlotsAsync(request.HomeBaseId))
                {
                    return(new Result <BikeResponse>(new BadRequestException(Error.HomeBaseFull)));
                }
            }

            return(await _bikeRepository.AddBikeAsync(request));
        }