Пример #1
0
        public static Nationality ConvertToNationality(this UpdateNationalityRequest updateRequest)
        {
            Nationality nationality = new Nationality();

            nationality.NationalityId   = updateRequest.NationalityId;
            nationality.NationalityName = updateRequest.Nationality;

            return(nationality);
        }
Пример #2
0
        public static UpdateNationalityRequest ConvertToUpdateNationalityRequest(this NationalityViewModel model)
        {
            UpdateNationalityRequest request = new UpdateNationalityRequest();

            request.NationalityId = model.NationalityId;
            request.Nationality   = model.Nationality;

            return(request);
        }
Пример #3
0
        public ActionResult Edit(NationalitySinglePageViewModel model)
        {
            UpdateNationalityRequest  request  = model.NationalityViewModel.ConvertToUpdateNationalityRequest();
            UpdateNationalityResponse response = _nationalityService.UpdateNatonality(request);

            if (response.Success)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                model.Success = false;
                model.Message = response.Message;
                return(View(model));
            }
        }
Пример #4
0
        public UpdateNationalityResponse UpdateNatonality(UpdateNationalityRequest request)
        {
            UpdateNationalityResponse response = new UpdateNationalityResponse();

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