public async Task <IActionResult> Add(AddBenchmarkExperimentViewModel viewModel)
        {
            var model = _mapper.Map <BenchmarkExperiment>(viewModel);

            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 CreateCommand <BenchmarkExperiment>(model));

            return(Ok(model.Id));
        }
        public async Task <IActionResult> Add()
        {
            var viewModel = new AddBenchmarkExperimentViewModel
            {
                Applications    = await ApplicationsSelectList(),
                ApacheTestFiles = await ApacheTestFilesSelectList(),
                Hosts           = await ApplicationHosts(),
                BenchmarkHosts  = await BenchmarkHosts(),
                DatabaseHosts   = await DatabaseHosts()
            };

            return(View(viewModel));
        }
        public async Task <IActionResult> Add([FromForm] AddBenchmarkExperimentViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Applications = await ApplicationsSelectList();

                viewModel.ApacheTestFiles = await ApacheTestFilesSelectList();

                viewModel.Hosts = await ApplicationHosts();

                viewModel.BenchmarkHosts = await BenchmarkHosts();

                viewModel.DatabaseHosts = await DatabaseHosts();

                return(View(viewModel));
            }

            var model = _mapper.Map <BenchmarkExperiment>(viewModel);

            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 CreateCommand <BenchmarkExperiment>(model));

            return(RedirectToAction("Details", new { id = model.Id }));
        }