protected override async Task OnParametersSetAsync() { _editContext = new EditContext(_tripFormModel); var result = int.TryParse(RunsheetId, out _id); _runsheet = await Unit.Runsheets.GetByIdAsync(_id); _activeTrip = await Unit.Trips.GetTripWithChildrenByRunsheetId(_id); if (_activeTrip != null) { _tripFormModel = TripMapper.MapTrip(_activeTrip, _tripFormModel); } if (_activeTrip == null) { _activeTrip = new Trip() { InProgress = true }; _tripFormModel.StartTime = LocalTimeUtility.GetLocalTime(); _tripFormModel.InProgress = true; } }
private async Task UpdateModel() { _activeTrip = TripMapper.MapTrip(_tripFormModel, _activeTrip); _runsheet = await Unit.Runsheets.GetByIdAsync(_id); if (_activeTrip.Id == 0) { _runsheet.Trips.Add(_activeTrip); await Unit.Runsheets.UpdateAsync(_runsheet); } else { await Unit.Trips.UpdateAsync(_activeTrip); } }