public ActionResult Create(NationalitySinglePageViewModel model)
        {
            if (ModelState.IsValid)
            {
                _nationalityService.CreateNationality(model.NationalityViewModel.ConvertToModel());
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        public async Task <IActionResult> Post([FromBody] Nationality nationality)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid View Model"));
            }

            await nationalityService.CreateNationality(nationality);

            return(StatusCode(201, "Nationality Created!"));
        }
Example #3
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));
            }
        }