public async Task <IActionResult> Edit([FromForm] EditBenchmarkExperimentViewModel viewModel) { if (!ModelState.IsValid) { viewModel.Hosts = await ApplicationHosts(); viewModel.BenchmarkHosts = await BenchmarkHosts(); viewModel.DatabaseHosts = await DatabaseHosts(); return(View(viewModel)); } var appTest = await _mediatr.Send(new GetEntityCommand <BenchmarkExperiment>(viewModel.Id)); if (appTest == null) { return(View(viewModel)); } var model = _mapper.Map(viewModel, appTest); if (viewModel.Application != Guid.Empty) { model.Application = await _mediatr.Send(new GetEntityCommand <Application>(viewModel.Application)); } if (viewModel.Host != Guid.Empty) { model.Host = await _mediatr.Send(new GetEntityCommand <DockerHost>(viewModel.Host)); } if (viewModel.BenchmarkHost != Guid.Empty) { model.BenchmarkHost = await _mediatr.Send(new GetEntityCommand <DockerHost>(viewModel.BenchmarkHost)); } if (viewModel.ApacheTestFileId != Guid.Empty) { if (viewModel.ApacheTestFileId != null) { model.TestFile = await _mediatr.Send(new GetEntityCommand <ApacheJmeterTestFile>(viewModel.ApacheTestFileId.Value)); } } model.ApacheJmeterTestId = viewModel.ApacheTestFileId; await _mediatr.Send(new UpdateCommand <BenchmarkExperiment>(model)); return(RedirectToAction("Details", new { id = model.Id })); }
public async Task <IActionResult> Edit([FromForm] EditBenchmarkExperimentViewModel viewModel) { var appTest = await _mediatr.Send(new GetEntityCommand <BenchmarkExperiment>(viewModel.Id)); if (appTest == null) { return(BadRequest("No Experiment found for given Id")); } var model = _mapper.Map(viewModel, appTest); if (viewModel.Application != Guid.Empty) { model.Application = await _mediatr.Send(new GetEntityCommand <Application>(viewModel.Application)); } if (viewModel.Host != Guid.Empty) { model.Host = await _mediatr.Send(new GetEntityCommand <DockerHost>(viewModel.Host)); } if (viewModel.BenchmarkHost != Guid.Empty) { model.BenchmarkHost = await _mediatr.Send(new GetEntityCommand <DockerHost>(viewModel.BenchmarkHost)); } if (viewModel.ApacheTestFileId != Guid.Empty) { if (viewModel.ApacheTestFileId != null) { model.TestFile = await _mediatr.Send(new GetEntityCommand <ApacheJmeterTestFile>(viewModel.ApacheTestFileId.Value)); } } model.ApacheJmeterTestId = viewModel.ApacheTestFileId; await _mediatr.Send(new UpdateCommand <BenchmarkExperiment>(model)); return(Ok()); }