コード例 #1
0
        public ActionResult Create(NationalitySinglePageViewModel model)
        {
            CreateNationalityRequest  request  = model.NationalityViewModel.ConvertToCreateNationalityRequest();
            CreateNationalityResponse response = _nationalityService.CreateNationality(request);

            if (response.Success)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                model.Success = false;
                model.Message = response.Message;
                return(View(model));
            }
        }
コード例 #2
0
        public CreateNationalityResponse CreateNationality(CreateNationalityRequest request)
        {
            CreateNationalityResponse response = new CreateNationalityResponse();

            try
            {
                Nationality nationality = request.ConvertToNationality();
                _nationalityRepository.Create(nationality);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }