public JsonResult CreateUser(string eMail, string pass) { try { //idUser = (int)System.Web.HttpContext.Current.Session["idUser"]; var eMailValid = MailService.IsEmail(eMail); if (!eMailValid) { data.message = "Se ha ingresado un email no valido"; data.status = "error"; return(Json(data, JsonRequestBehavior.AllowGet)); } if (UserService.spGetUse(eMail).Rows.Count > 0) { data.message = "Ya existe una cuenta con el mail ingresado"; data.status = "error"; return(Json(data, JsonRequestBehavior.AllowGet)); } EncryptPass = ServiceEncryp.Encryp(pass); UserService.CreateUser(eMail, EncryptPass); } catch (Exception ex) { data.message = ex.Message; data.status = "error"; return(Json(data, JsonRequestBehavior.AllowGet)); } return(Json(data, JsonRequestBehavior.AllowGet)); }
public JsonResult CreateNewUserOperator(string EMail) { try { if (!mailService.IsEmail(EMail)) { data.message = "El EMail ingresado no es valido"; data.status = "error"; } else { idCompany = (int)System.Web.HttpContext.Current.Session["idcompany"]; var countLic = (int)UserService.SpCountLicense(idCompany).Rows[0][0]; if (countLic == 0) { data.message = "Se puede crear hasta 4 usuarios"; data.status = "error"; return(Json(data, JsonRequestBehavior.AllowGet)); } var GeneratePass = UserService.GenerateCode(); EncryptPass = ServiceEncryp.Encryp(GeneratePass); dt = UserService.SpCreateUserOperator(EMail, idCompany, EncryptPass); //mailService.SendMail(EMail, "Nuevo usuario", "Nueva Contraseña: " + EncryptPass); data.message = "Se creo el Usuario con exito"; } } catch (Exception ex) { data.message = ex.Message; data.status = "error"; return(Json(data, JsonRequestBehavior.AllowGet)); } return(Json(data, JsonRequestBehavior.AllowGet)); }