public ActionResult SearchJob() { if (IsLoggedIn()) { try { var talentoId = Request.QueryString["tid"]; var empresaId = Request.QueryString["eid"]; if (empresaId != "-1") { using (var db = new TalenterEntities1()) { db.Database.ExecuteSqlCommand("INSERT INTO DBO.VISITADOS(ID_EMPRESA, ID_TALENTO) VALUES (@emp, @tal)", new SqlParameter("@emp", empresaId), new SqlParameter("@tal", talentoId)); } } } catch (Exception e) { Console.WriteLine(e.Message); } EMPRESA empresa = null; using (var db = new TalenterEntities1()) { Talento = db.TALENTO.SqlQuery("SELECT * FROM TALENTO WHERE ID_Talento = @id", new SqlParameter("@id", Session["UserId"])).FirstOrDefault(); empresa = db.EMPRESA.SqlQuery(@"SELECT TOP 1 E.* FROM EMPRESA E JOIN TALENTO T ON E.ID_RUBRO = T.ID_RUBRO WHERE E.ID_EMPRESA NOT IN ( SELECT v.ID_EMPRESA FROM Visitados v JOIN Talento t ON v.ID_Talento = t.ID_Talento JOIN EMPRESA E ON V.ID_EMPRESA = E.ID_EMPRESA WHERE t.ID_Talento = @id) AND T.ID_TALENTO = @id", new SqlParameter("@id", Talento.ID_TALENTO)).FirstOrDefault(); if (empresa == null) { empresa = new EMPRESA { ID_EMPRESA = -1, NOMBRE = "Ya no hay mas empresas!", ABOUT = "Ya visitaste todas las empresas de tu rubro! Espera a que aparezcan mas!", RUBRO = Talento.RUBRO }; } Session["eid"] = empresa.ID_EMPRESA; } return(View(empresa)); } return(RedirectToAction("Login")); }
public ActionResult Login(TALENTO model, string returnUrl) { using (TalenterEntities1 DB = new TalenterEntities1()) { var user = DB.TALENTO.Where(x => x.EMAIL == model.EMAIL && x.PASSWORD == model.PASSWORD).FirstOrDefault(); if (user != null) { Session["UserId"] = user.ID_TALENTO; Session["Email"] = user.EMAIL; Session["Name"] = user.NOMBRE; Talento = user; return(RedirectToAction("SearchJob")); } else { ModelState.AddModelError("", "Username or Password is Incorrect"); return(View()); } } }