public JsonResult ValidaNombreRol(string nombre, bool editando) { if (editando) { return(Json(true, JsonRequestBehavior.AllowGet)); } CotizarService.CotizarServiceClient objService = new CotizarService.CotizarServiceClient(); if (objService.Rol_ValidaNombre(new CotizarService.Rol() { nombre = nombre })) { return(Json(true, JsonRequestBehavior.AllowGet)); } string suggestedUID = String.Format(CultureInfo.InvariantCulture, "{0} no está disponible.", nombre); for (int i = 1; i < 100; i++) { string altCandidate = nombre + i.ToString(); if (objService.Rol_ValidaNombre(new CotizarService.Rol() { nombre = altCandidate })) { suggestedUID = String.Format(CultureInfo.InvariantCulture, "{0} no está disponible. Te sugerimos usar {1}.", nombre, altCandidate); break; } } return(Json(suggestedUID, JsonRequestBehavior.AllowGet)); }
public JsonResult ValidaNombreRol(string nombre, bool editando) { if (editando) return Json(true, JsonRequestBehavior.AllowGet); CotizarService.CotizarServiceClient objService = new CotizarService.CotizarServiceClient(); if (objService.Rol_ValidaNombre(new CotizarService.Rol() { nombre = nombre })) return Json(true, JsonRequestBehavior.AllowGet); string suggestedUID = String.Format(CultureInfo.InvariantCulture, "{0} no está disponible.", nombre); for (int i = 1; i < 100; i++) { string altCandidate = nombre + i.ToString(); if (objService.Rol_ValidaNombre(new CotizarService.Rol() { nombre = altCandidate })) { suggestedUID = String.Format(CultureInfo.InvariantCulture, "{0} no está disponible. Te sugerimos usar {1}.", nombre, altCandidate); break; } } return Json(suggestedUID, JsonRequestBehavior.AllowGet); }