public ActionResult RecetasDeRecetero(Receteros rec) { int id = Convert.ToInt32(Session["User"]); ViewBag.Logged = Logged; ViewBag.ListaRecetasXRecetero = BD.ListarRecetasXRecetero(id); return(View()); }
public static void IngresarRecetero(Receteros rec) { SqlConnection Conexion = Conectar(); SqlCommand consulta = Conexion.CreateCommand(); consulta.CommandType = System.Data.CommandType.Text; consulta.CommandText = "Insert into Receteros (Nombre, Apellido, Descripcion, Foto, Edad, Email, Username, Password) values('" + rec.Nombre1 + "'," + rec.Apellido1 + "'," + rec.Descripcion1 + "'," + rec.NombreImagen1 + "'," + rec.Edad1 + "'," + rec.Email1 + "'," + rec.Username1 + "'," + rec.Password1 + ")"; consulta.ExecuteNonQuery(); }
public ActionResult Grabar(Receteros rec) { ViewBag.Logged = Logged; if (ModelState.IsValid) { if (rec.Foto1 != null) { string NuevaUbicacion = Server.MapPath("~/Content/img/") + rec.Foto1.FileName; rec.Foto1.SaveAs(NuevaUbicacion); rec.NombreImagen1 = rec.Foto1.FileName; } BD.IngresarRecetero(rec); return(RedirectToAction("Index")); } else { ViewBag.Recetero = rec; return(View("Registrarse")); } }
public static int ValidarLoginFront(Receteros user) { SqlConnection Conexion = Conectar(); SqlCommand consulta = Conexion.CreateCommand(); consulta.CommandType = System.Data.CommandType.Text; consulta.CommandText = "Select * from Receteros"; SqlDataReader dataReader = consulta.ExecuteReader(); int validar = -1; while (dataReader.Read() && validar == -1) { string usuario = dataReader["Username"].ToString(); string contrasenia = dataReader["Password"].ToString(); if (usuario == user.Username1 && contrasenia == user.Password1) { validar = Convert.ToInt32(dataReader["idReceteros"]); } } Desconectar(Conexion); return(validar); }
public ActionResult Loguearse(Receteros user) { if (!ModelState.IsValid) { return(View("Login")); } else { int validaruser = BD.ValidarLoginFront(user); if (validaruser > -1) { Session["User"] = validaruser; int id = Convert.ToInt32(Session["User"]); Logged = true; ViewBag.Logged = Logged; return(RedirectToAction("Index", "Front")); } else { ViewBag.Error = "Usuario o contraseña incorrecta"; return(View("Login")); } } }