public async Task <int> PayAccidentFine(Guid accidentId) { var accident = await GetAccidentById(accidentId); accident.Fine = 0; _dbContext.Entry(accident).State = EntityState.Modified; return(await SaveChanges()); }
public async Task <int> RemoveTrip(string tripId) { var foundTrip = await _dbContext.Trips.FindAsync(tripId); if (foundTrip != null) { foundTrip.IsActive = false; _dbContext.Entry(foundTrip).State = EntityState.Modified; } return(await SaveChanges()); }
public async Task <ServiceResponse> GetVehicleByIdReadOnly(string vehicleId) { var response = new ServiceResponse(); var vehicle = await _dbContext.Vehicles.FindAsync(vehicleId); if (vehicle == null) { throw new Exception("No vehicle with the given Id was found"); } _dbContext.Entry(vehicle).State = EntityState.Detached; var vehicleDto = _mapper.Map <VehicleDto>(vehicle); response.Message = "Vehicle details loaded successfully"; response.Data = vehicleDto; response.Success = true; return(response); }