예제 #1
0
        public async Task <VehicleResponse <VehicleMake> > DeleteAsync(Guid id)
        {
            var existingVehicleMake = await _vehicleMakeRepository.FindMakeByIdAsync(id);

            if (existingVehicleMake == null)
            {
                return(new VehicleResponse <VehicleMake>("VehicleMake not found."));
            }

            try
            {
                await _vehicleMakeRepository.DeleteMakeAsync(existingVehicleMake);

                await _unitOfWork.CompleteAsync();

                return(new VehicleResponse <VehicleMake>(existingVehicleMake));
            }
            catch (Exception ex)
            {
                return(new VehicleResponse <VehicleMake>($"An error occurred when deleting the vehicleMake: {ex.Message}"));
            }
        }