public async Task <bool> Handle(UpdateFlightRealTimeCommand request, CancellationToken cancellationToken) { var flight = await _flightRepo.Get(request.FlightId); if (flight == null) { // TRHOW EXCEPTION } flight.RealArrivalTime = request.RealArrival; flight.RealDepartureTime = request.RealDeparture; flight.IsConfirmed = true; if (request.Reason != null) { flight.LateReason = request.Reason; } var plane = flight.Plane; plane.TimesUsed++; if (plane.TimesUsed == 6) { plane.State = State.Garage; } await _planeRepo.UpdateStatus(plane); await _flightRepo.Update(flight); return(true); }
public async Task <bool> Handle(UpdatePlaneToOkStatusCommand request, CancellationToken cancellationToken) { var plane = _repo.Get(request.PlaneId).Result; plane.UpdateStateToOk(); await _repo.UpdateStatus(plane); return(true); }
public async Task <bool> Handle(UpdatePlaneStatusCommand request, CancellationToken cancellationToken) { var plane = _repo.Get(request.Id).Result; if (plane == null) { // THROW EXCEPTION } plane.CheckAndUpdateState(); await _repo.UpdateStatus(plane); return(true); }