public JsonResult RegistrarNuevoUsuario() { string res = "false"; try { OperacionesUsuarios opUsers = new OperacionesUsuarios(); string username = Request["nombreUsuario"]; string pass = Request["password"]; string pnom = Request["pnombre"]; string snom = Request["snombre"]; string apellidoPat = Request["apat"]; string apmat = Request["amat"]; DateTime fecha = DateTime.Now; int tipo = 2; string email = Request["email"]; opUsers.Guardar(username, pass, pnom, snom, apellidoPat, apmat, fecha, tipo, email); res = "true"; } catch (Exception ex) { res = ex.Message; } return(Json(res)); }
public JsonResult Guardar() { string res = "false"; try { string bd = Request["bd"]; if (bd == "Mensajes") { string texto = texto = Request["textoMensaje"]; string date = DateTime.Now.ToString(); string emailR = Request["emailRemitente"]; OperacionesMensajes opmen = new OperacionesMensajes(); opmen.Guardar(texto, date, emailR); } else if (bd == "Productos") { string nom = Request["nombreProducto"]; int precio = int.Parse(Request["precio"]); int stock = int.Parse(Request["stock"]); OperacionesProductos opprod = new OperacionesProductos(); opprod.Guardar(nom, precio, stock); } else if (bd == "Noticias") { DateTime fecha = DateTime.Now; string texto = Request["textoNoticia"]; int idAutor = int.Parse(Request["idAutor"]); OperacionesNoticias opnot = new OperacionesNoticias(); opnot.Guardar(fecha, texto, idAutor); } else if (bd == "Usuarios") { string nomusu = Request["nombreUsuario"]; string password = Request["password"]; string pnombre = Request["pnombre"]; string snombre = Request["snombre"]; string apat = Request["apat"]; string apmat = Request["apmat"]; DateTime fecha = DateTime.Now; int tipo = 0; if (Request["tipo"].ToString() == "Administrador") { tipo = 1; } else if (Request["tipo"].ToString() == "Cliente") { tipo = 2; } else { throw new Exception("tipo de usuario no valido"); } string email = Request["email"]; OperacionesUsuarios opusu = new OperacionesUsuarios(); opusu.Guardar(nomusu, password, pnombre, snombre, apat, apmat, fecha, tipo, email); } else if (bd == "Ventas") { OperacionesVentas opven = new OperacionesVentas(); int iduser = int.Parse(Request["idUsuario"]); int producto = int.Parse(Request["idProducto"]); if (!opven.Guardar(iduser, producto, DateTime.Now)) { throw new Exception("no se guardo"); } } res = "true"; } catch (Exception e) { res = e.Message; } return(Json(res)); }