public static Nationality ConvertToNationality(this UpdateNationalityRequest updateRequest) { Nationality nationality = new Nationality(); nationality.NationalityId = updateRequest.NationalityId; nationality.NationalityName = updateRequest.Nationality; return(nationality); }
public static UpdateNationalityRequest ConvertToUpdateNationalityRequest(this NationalityViewModel model) { UpdateNationalityRequest request = new UpdateNationalityRequest(); request.NationalityId = model.NationalityId; request.Nationality = model.Nationality; return(request); }
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)); } }
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); }