public async Task <ActionResult> Results(TraineeshipSearchViewModel model)
        {
            return(await Task.Run <ActionResult>(() =>
            {
                ViewBag.SearchReturnUrl = (Request != null && Request.Url != null) ? Request.Url.PathAndQuery : null;

                var response = _traineeshipSearchMediator.Results(model);

                switch (response.Code)
                {
                case TraineeshipSearchMediatorCodes.Results.ValidationError:
                    ModelState.Clear();
                    response.ValidationResult.AddToModelState(ModelState, string.Empty);
                    return View(response.ViewModel);

                case TraineeshipSearchMediatorCodes.Results.HasError:
                    ModelState.Clear();
                    SetUserMessage(response.Message.Text, response.Message.Level);
                    return View(response.ViewModel);

                case TraineeshipSearchMediatorCodes.Results.Ok:
                    ModelState.Remove("Location");
                    ModelState.Remove("Latitude");
                    ModelState.Remove("Longitude");

                    return View(response.ViewModel);
                }

                throw new InvalidMediatorCodeException(response.Code);
            }));
        }
        public async Task <ActionResult> Results(TraineeshipSearchViewModel model)
        {
            return(await Task.Run <ActionResult>(() =>
            {
                ViewBag.SearchReturnUrl = Request?.Url?.PathAndQuery;

                var response = _traineeshipSearchMediator.Results(model);

                switch (response.Code)
                {
                case TraineeshipSearchMediatorCodes.Results.ValidationError:
                    ModelState.Clear();
                    response.ValidationResult.AddToModelState(ModelState, string.Empty);
                    return View(response.ViewModel);

                case TraineeshipSearchMediatorCodes.Results.HasError:
                    ModelState.Clear();
                    SetUserMessage(response.Message.Text, response.Message.Level);
                    return View(response.ViewModel);

                case TraineeshipSearchMediatorCodes.Results.ExactMatchFound:
                    ViewBag.SearchReturnUrl = null;
                    return RedirectToRoute(CandidateRouteNames.TraineeshipDetails, response.Parameters);

                case TraineeshipSearchMediatorCodes.Results.Ok:
                    ModelState.Remove("Location");
                    ModelState.Remove("Latitude");
                    ModelState.Remove("Longitude");
                    return View(response.ViewModel);
                }

                throw new InvalidMediatorCodeException(response.Code);
            }));
        }