public ActionResult CrearEditCentro(int CentroId, string Centro, string Ciudad, string Pais) { var parameters = new RouteValueDictionary(); SaveCentroResponse response = null; response = _candidatoCentroService.SaveCentro(CentroId, Centro, Ciudad, Pais); if (!response.IsValid) { parameters.Add("errorMessage", response.ErrorMessage); } return(RedirectToAction("Create", "Candidatos", parameters)); }
public SaveCentroResponse SaveCentro(int idCentro, string centro, string ciudad, string pais) { var response = new SaveCentroResponse(); try { var centroGuardar = _becarioCentroRepository.GetOne(x => x.BecarioCentroProcedenciaId == idCentro && x.IsActivo); if (centroGuardar == null) { BecarioCentroProcedencia nuevoCentro = new BecarioCentroProcedencia() { Centro = centro, Ciudad = ciudad, Pais = pais, IsActivo = true }; _becarioCentroRepository.Create(nuevoCentro); } else { centroGuardar.Centro = centro; centroGuardar.Ciudad = ciudad; centroGuardar.Pais = pais; _becarioCentroRepository.Update(centroGuardar); } response.IsValid = true; } catch (Exception ex) { response.IsValid = false; response.ErrorMessage = ex.Message; } return(response); }