コード例 #1
0
        public ActionResult SaveEmployer(EmployerViewModel viewModel)
        {
            var response = _adminMediator.SaveEmployer(viewModel);

            ModelState.Clear();

            SetUserMessage(response.Message);

            switch (response.Code)
            {
            case AdminMediatorCodes.SaveEmployer.FailedValidation:
                response.ValidationResult.AddToModelState(ModelState, "SearchViewModel");
                return(View("Employer", response.ViewModel));

            case AdminMediatorCodes.SaveEmployer.Error:
                return(RedirectToRoute(ManagementRouteNames.AdminViewEmployer, new { viewModel.EmployerId }));

            case AdminMediatorCodes.SaveEmployer.Ok:
                return(RedirectToRoute(ManagementRouteNames.AdminViewEmployer, new { viewModel.EmployerId }));

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