コード例 #1
0
        public async Task <bool> DeleteCarAsync(int dealerId, int id)
        {
            var car = await GetCarAsync(dealerId, id);

            if (car == null)
            {
                throw new NotFoundException($"The car with {id} does not exist in the dealership.");
            }
            await repository.DeleteCarAsync(id);

            var deal = await repository.SaveChangesAsync();

            if (deal)
            {
                return(true);
            }

            throw new Exception("Database Exception");
        }