public ActionResult actualizar(int idPublicacion, string Titulo, HttpPostedFileBase Portada, HttpPostedFileBase Contenido, string Descripcion, publicmodel model) { DataClasses1DataContext db=new DataClasses1DataContext(); using(DataClasses1DataContext dd=new DataClasses1DataContext()){ var libro = (from l in dd.publicacion where l.idPublicacion == idPublicacion select l).Single(); libro.titulo = Titulo; if (Portada != null) { var data = new byte[Portada.ContentLength]; Portada.InputStream.Read(data, 0, Portada.ContentLength); var path = ControllerContext.HttpContext.Server.MapPath("~/Content/Imagenes/"); var filename = Path.Combine(path, Path.GetFileName(Portada.FileName)); System.IO.File.WriteAllBytes(Path.Combine(path, filename), data); libro.portada = (Portada.FileName).ToString(); } else { libro.portada = libro.portada; } if (Contenido != null) { var data2 = new byte[Contenido.ContentLength]; Portada.InputStream.Read(data2, 0, Contenido.ContentLength); var path1 = ControllerContext.HttpContext.Server.MapPath("~/Content/ArchivoPDF/"); var filename1 = Path.Combine(path1, Path.GetFileName(Contenido.FileName)); System.IO.File.WriteAllBytes(Path.Combine(path1, filename1), data2); libro.contenido = (Contenido.FileName).ToString(); } else { libro.contenido = libro.contenido; } libro.correcciones = "false"; libro.descripcion = Descripcion; dd.SubmitChanges(); } return RedirectToAction("reedicion", "reedicion"); }
public JsonResult cargardatos() { GridDemo grid = new GridDemo(); DataClasses1DataContext db = new DataClasses1DataContext(); return grid.grid.DataBind(db.perfil); }
public ActionResult tutorial(string Titulo, HttpPostedFileBase Portada, string Contenido, string Categoria, string Descripcion,tutoriales model) { if (ModelState.IsValid) { DataClasses1DataContext db = new DataClasses1DataContext(); model.Titulo = Titulo; if (Portada != null) { var data2 = new byte[Portada.ContentLength]; Portada.InputStream.Read(data2, 0, Portada.ContentLength); var path = ControllerContext.HttpContext.Server.MapPath("/Content/Imagenes/"); var filename = Path.Combine(path, Path.GetFileName(Portada.FileName)); System.IO.File.WriteAllBytes(Path.Combine(path, filename), data2); model.Portada = (Portada.FileName).ToString(); } else { model.Portada = "imagenxdefecto.jpg"; } model.Contenido = Contenido; model.Categoria = Categoria; model.Descripcion = Descripcion; model.idusers = (Guid)Membership.GetUser().ProviderUserKey; string categori = model.Categoria; model.regpublit(model); int idUs = db.publicacion.Where(m => m.titulo == model.Titulo).Select(m => m.idPublicacion).ToArray()[0]; //int idcat = db.categoria.Where(c => c.tipo == model.Categoria).Select(c => c.idCategoria).ToArray()[0]; model.regtutorial(idUs); char[] delimiterChars = { ' ', ',', '.', ':' }; string[] words = categori.Split(delimiterChars); DataClasses1DataContext db2 = new DataClasses1DataContext(); List<categoria> lista = new List<categoria>(); string tipo = ""; //int cat3 = 0; foreach (var s in words) { string ls = s.Trim(); if (db2.categoria.Where(a => a.tipo == ls).Count() == 0) { lista.Add(new categoria() { tipo = ls }); } } if (lista.ToList().Count > 0) { db.categoria.InsertAllOnSubmit(lista); db.SubmitChanges(); int cat = (from a in db.categoria where a.tipo == tipo select a.idCategoria).ToArray()[0]; model.regcategorizaciont(idUs, cat); } } return RedirectToAction("tutorial", "tutorial"); }
public ActionResult editcoment(int id) { using (DataClasses1DataContext db = new DataClasses1DataContext()) { var visto = (from a in db.comentarios where a.idComentarios == id select a).Single(); visto.vistobueno = "true"; db.SubmitChanges(); } return RedirectToAction("coment1", "coment"); }
public ActionResult rechazarsol(Guid UserId) { using (DataClasses1DataContext db = new DataClasses1DataContext()) { ViewBag.p = (from c in db.solisitud where c.UserId == UserId select c).ToList(); foreach (var del in @ViewBag.p) db.solisitud.DeleteOnSubmit(del); db.SubmitChanges(); } return RedirectToAction("aceptsolisitud", "solisitud"); }
public ActionResult aceptsolisitud() { DataClasses1DataContext db =new DataClasses1DataContext(); ViewBag.sol = (from s in db.solisitudes select s).ToList(); if (ViewBag.sol != null) { ViewBag.sol = (from s in db.solisitudes select s).ToList(); } else { ViewBag.sol = "Sin Solisitudes"; } return View(); }
public GetFile DownloadFile(int id) { DataClasses1DataContext db = new DataClasses1DataContext(); var pu = (from p in db.publicacion where p.idPublicacion == id select p).ToArray()[0]; return new GetFile { FileName = pu.contenido, Path = @"~/Content/ArchivoPDF/" + pu.contenido }; }
public void regperfil(Guid idus) { DataClasses1DataContext db = new DataClasses1DataContext(); perfil perfl = new perfil() { infraccion = 0, karma = 0, beneado = "false", UserId = idus }; db.perfil.InsertOnSubmit(perfl); db.SubmitChanges(); }
public void editardatos(perfil per) { GridDemo grid = new GridDemo(); if(grid.grid.AjaxCallBackMode == AjaxCallBackMode.EditRow){ DataClasses1DataContext db = new DataClasses1DataContext(); perfil update = db.perfil.Where(a => a.idPerfil == per.idPerfil).First<perfil>(); update.idPerfil = per.idPerfil; update.infraccion = per.infraccion; update.karma = per.karma; update.beneado = per.beneado; db.SubmitChanges(); } }
public ActionResult articulos() { DataClasses1DataContext db = new DataClasses1DataContext(); articulos art = new articulos(); art = (from a in db.articulos select a).ToArray()[0]; if (art != null) { ViewBag.arti = (from a in db.articulos select a).ToArray()[0]; ViewBag.ca = (from c in db.categorias where c.idPublicacion == art.idpublicacion select c).ToArray()[0]; } else { ViewBag.error = "No existe ningun registro"; } return View(); }
public ActionResult Cursos() { DataClasses1DataContext db = new DataClasses1DataContext(); var lista = db.listcur.ToList().Take(10).OrderByDescending(a => a.fecha_publicacion); if (lista != null) { ViewBag.lib = lista; } else { ViewBag.lib = "No se encontro ningun registro"; } publicacion p = new publicacion(); ViewBag.p = db.publicacion.ToList().Take(10).OrderByDescending(a => a.idPublicacion); ViewBag.tipo = (from t in db.categoria select t).ToList(); return View(); }
public ActionResult detalletutorial() { DataClasses1DataContext db = new DataClasses1DataContext(); Guid id = (Guid)Membership.GetUser().ProviderUserKey; ViewBag.publi = (from p in db.publicacion join l in db.tutorial on p.idPublicacion equals l.idPublicacion where p.idPublicacion == l.idPublicacion && p.UserId == id select p).ToList(); if (ViewBag.publi != null) { ViewBag.publi = (from p in db.publicacion join l in db.tutorial on p.idPublicacion equals l.idPublicacion where p.idPublicacion == l.idPublicacion && p.UserId == id select p).ToList(); ViewBag.datos = (from f in db.perfilusers where f.UserId == id select f).ToList(); ViewBag.perfil = (from d in db.perfil where d.UserId == id select d).ToList(); } else { ViewBag.publi = "Usted no tiene Contenidos de libros publicados"; } return View(); }
public ActionResult aceptarsol(Guid UserId,soliadmin model) { DataClasses1DataContext db = new DataClasses1DataContext(); Guid idu = UserId; Guid idr=(from r in db.aspnet_Roles where r.RoleName=="Administrador" select r.RoleId).ToArray()[0]; model.regroll(idu,idr); using (DataClasses1DataContext dbb = new DataClasses1DataContext()) { ViewBag.p = (from c in dbb.solisitud where c.UserId == UserId select c).ToList(); foreach (var del in @ViewBag.p) db.solisitud.DeleteOnSubmit(del); db.SubmitChanges(); } return RedirectToAction("aceptsolisitud", "solisitud"); }
public void comentario(buscar model) { DataClasses1DataContext db = new DataClasses1DataContext(); comentarios c = new comentarios() { contenido=model.Comentario, vistobueno="false", fecha_publicacion=DateTime.Now, idPublicacion = model.idPublicacion, UserId=model.UserId }; db.comentarios.InsertOnSubmit(c); db.SubmitChanges(); }
public ActionResult detalle() { DataClasses1DataContext db = new DataClasses1DataContext(); Guid id = (Guid)Membership.GetUser().ProviderUserKey; ViewBag.coment = (from c in db.comentarios where c.UserId == id select c).ToList(); if (ViewBag.coment != null) { //ViewBag.publi = (from p in db.publicacion where p.UserId == id select p).ToList(); ViewBag.coment = (from c in db.comentarios where c.UserId == id select c).ToList(); ViewBag.datos = (from f in db.perfilusers where f.UserId == id select f).ToList(); ViewBag.perfil = (from d in db.perfil where d.UserId == id select d).ToList(); } else { ViewBag.coment = "Usted no tiene Comentarios"; } return View(); }
public ActionResult corregir(int id) { using (DataClasses1DataContext db = new DataClasses1DataContext()) { //var visto = (from o in db.publicacion join l in db.libro on o.idPublicacion equals l.idPublicacion where o.idPublicacion == l.idPublicacion && o.correcciones == "false" select o).Single(); var visto = (from p in db.publicacion where p.idPublicacion == id select p).Single(); //var karma = (from o in db.perfil where o.UserId == visto.UserId select o).Single(); //var kar = (from o in db.perfil where o.idPublicacion == id select o).Single(); visto.correcciones = "corregir"; //karma.karma += 50; db.SubmitChanges(); } return Redirect("/modcontenido/mod"); }
public ActionResult coment1() { DataClasses1DataContext db = new DataClasses1DataContext(); var m = (from d in db.mode_coment select d).ToList(); if (m != null) { var contenido = db.mode_coment.ToList().Take(1).OrderByDescending(a => a.idComentarios); ViewBag.contenido = contenido; ViewBag.cat = (from c in db.mode_coment select c).ToList(); } else { ViewBag.error = "No Existe Comentarios por Revisar"; } return View(); }
public ActionResult detallearticulo(int id) { DataClasses1DataContext db = new DataClasses1DataContext(); var lista = db.listaart.ToList().Where(a => a.idpublicacion == id); if (lista != null) { ViewBag.lib = lista; ViewBag.l= id; } else { ViewBag.lib = "No se encontro ningun registro"; } //ViewBag.tipol = (from tip in db.categoriaarticulo where tip.idpublicacion == id select tip).ToArray()[0]; publicacion p = new publicacion(); ViewBag.p = db.publicacion.ToList().Take(10).OrderByDescending(a => a.idPublicacion); ViewBag.tipo = (from t in db.categoria select t).ToList(); ViewBag.comentario = (from m in db.comentario where m.idpublicacion == id select m).ToList(); return View(); }
public ActionResult coment(int id) { if (id == null) { DataClasses1DataContext db = new DataClasses1DataContext(); ///List<mode_coment> m = new List<mode_coment>(); var m = (from d in db.mode_coment select d).ToList(); if (m != null) { ViewBag.contenido = (from d in db.mode_coment where d.idComentarios == id select d).ToList(); ViewBag.cat = (from c in db.mode_coment select c).ToList(); ViewBag.p = (from d in db.mode_coment where d.idComentarios == id select d).ToList(); char[] delimiterChars = new char[]{ ' ', ',', '.', ';',':' }; var ofensivo = @ViewBag.p.Split(delimiterChars); foreach (var ofen in ofensivo) { if (@ofen == "carajo" || @ofen == "mierda" || @ofen == "sonso" || @ofen == "chafa" || @ofen == "puto") { ViewBag.img = "escorpion.jpg"; } else { ViewBag.img1 = "yes1.jpg"; } } } else { ViewBag.error = "No Existe Comentarios por Revisar"; } return View(); } else { DataClasses1DataContext db = new DataClasses1DataContext(); var contenido = (from d in db.mode_coment where d.idComentarios == id select d).ToList(); ViewBag.contenido = contenido; ViewBag.cat = (from c in db.mode_coment select c).ToList(); return View(); } }
public ActionResult LogOn(LogOnModel model, string returnUrl) { //validacion de usuario con permisos if (ModelState.IsValid) { //REVISION DE BENEADO DataClasses1DataContext db = new DataClasses1DataContext(); if (Membership.ValidateUser(model.UserName, model.Password)) { var beneado = (from p in db.perfil join us in db.aspnet_Users on p.UserId equals us.UserId where p.UserId == us.UserId && us.UserName == model.UserName select p.beneado).ToArray()[0]; if (beneado == "false") { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { return RedirectToAction("login", "Home"); } } else { ViewBag.beneado = "Lo Sentimos usted esta Beneado por lo tanto no tiene permiso de ver la Pagina"; return RedirectToAction("login", "Home"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect.(Error de Nombreo Contraseña)"); if (Session["captcha"] != null && (int)Session["captcha"] > 2 && !ReCaptcha.Validate(privateKey: "6LcD79ESAAAAAHuI-gZuvfEPESrpzMaO-8fT8Bsy")) { ModelState.AddModelError("", "Verifique la Imagen Captvha. Por favor, inténtelo de nuevo "); } if (Session["captcha"] == null) { Session["captcha"] = 0; } int c = (int)Session["captcha"]; c++; Session["captcha"] = c; } // If we got this far, something failed, redisplay form return View(model); } return View(model); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); if (createStatus == MembershipCreateStatus.Success) { //registro usuarioroles DataClasses1DataContext db = new DataClasses1DataContext(); //var registro = from UsersId in db.aspnet_Users select UsersId; System.Guid idUs = db.aspnet_Users.Where(a => a.UserName == model.UserName).Select(a => a.UserId).ToArray()[0]; System.Guid idRol = db.aspnet_Roles.Where(a => a.RoleName == "Cliente").Select(a => a.RoleId).ToArray()[0]; aspnet_UsersInRoles rel = new aspnet_UsersInRoles() { RoleId = idRol, UserId = idUs }; db.aspnet_UsersInRoles.InsertOnSubmit(rel); db.SubmitChanges(); //registro usuarioroles FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult detalle(int id) { DataClasses1DataContext db = new DataClasses1DataContext(); return View(); }
public ActionResult usuario() { DataClasses1DataContext db = new DataClasses1DataContext(); ViewBag.pu = (from p in db.perfilusers select p).ToList(); ViewBag.per = (from pr in db.perfil select pr).ToList(); return View(); }
public ActionResult modtutorial(int id) { DataClasses1DataContext db = new DataClasses1DataContext(); var publi = (from p in db.publicacion where p.idPublicacion == id select p).ToArray()[0]; var tutorial = (from t in db.tutorial where t.idPublicacion == publi.idPublicacion select t).ToArray()[0]; if (tutorial != null) { ViewBag.pub = (from o in db.publicacion join a in db.tutorial on o.idPublicacion equals a.idPublicacion where o.idPublicacion == a.idPublicacion select o).ToList(); ViewBag.publi = (from p in db.publicacion where p.idPublicacion == id select p).ToList(); ViewBag.tutorial = (from t in db.tutorial where t.idPublicacion == publi.idPublicacion select t).ToList(); ViewBag.sms = "tutorial"; return View(); } else { ViewBag.error = "Sin Cursos"; return View(); } }
public ActionResult modcurso(int id) { DataClasses1DataContext db = new DataClasses1DataContext(); var publi = (from p in db.publicacion where p.idPublicacion == id select p).ToArray()[0]; var curso = (from c in db.curso where c.idPublicacion == publi.idPublicacion select c).ToArray()[0]; if (curso != null) { ViewBag.pub = (from o in db.publicacion join a in db.curso on o.idPublicacion equals a.idPublicacion where o.idPublicacion == a.idPublicacion select o).ToList(); ViewBag.publi = (from p in db.publicacion where p.idPublicacion == id select p).ToList(); ViewBag.curso = (from c in db.curso where c.idPublicacion == publi.idPublicacion select c).ToList(); ViewBag.sms = "curso"; return View(); } else { ViewBag.error = "Sin Cursos"; return View(); } }
public ActionResult modcontenido(int id) { DataClasses1DataContext db = new DataClasses1DataContext(); var libroo = (from l in db.libro where l.idPublicacion ==id select l).ToArray()[0]; var publi = (from p in db.publicacion where p.idPublicacion == libroo.idPublicacion select p).ToList(); if (libroo != null) { ViewBag.pub = (from o in db.publicacion join l in db.libro on o.idPublicacion equals l.idPublicacion where o.idPublicacion == l.idPublicacion select o).ToList(); ViewBag.publi = (from p in db.publicacion where p.idPublicacion == id select p).ToList(); ViewBag.libro = (from l in db.libro where l.idPublicacion == id select l).ToArray()[0]; ViewBag.sms = "libro"; return View(); } else { ViewBag.error = "Sin libros"; return View(); } }
public ActionResult modarticulo(int id) { DataClasses1DataContext db = new DataClasses1DataContext(); var articulo = (from a in db.articulo where a.idPublicacion == id select a).ToArray()[0]; var publi = (from p in db.publicacion where p.idPublicacion == articulo.idPublicacion select p).ToList(); if (articulo != null) { ViewBag.pub = (from o in db.publicacion join a in db.articulo on o.idPublicacion equals a.idPublicacion where o.idPublicacion == a.idPublicacion select o).ToList(); ViewBag.publi = (from p in db.publicacion where p.idPublicacion == id select p).ToList(); ViewBag.articulo = (from a in db.articulo where a.idPublicacion == articulo.idPublicacion select a).ToList(); ViewBag.sms = "articulo"; return View(); } else { ViewBag.error = "Sin Articulos"; return View(); } }
public ActionResult mod() { DataClasses1DataContext db = new DataClasses1DataContext(); ViewBag.pub1 = (from o in db.publicacion join l in db.libro on o.idPublicacion equals l.idPublicacion where o.idPublicacion == l.idPublicacion && o.correcciones=="false" select o).ToList(); ViewBag.pub2 = (from o in db.publicacion join a in db.articulo on o.idPublicacion equals a.idPublicacion where o.idPublicacion == a.idPublicacion && o.correcciones == "false" select o).ToList(); ViewBag.pub3 = (from o in db.publicacion join a in db.curso on o.idPublicacion equals a.idPublicacion where o.idPublicacion == a.idPublicacion && o.correcciones == "false" select o).ToList(); ViewBag.pub4 = (from o in db.publicacion join a in db.tutorial on o.idPublicacion equals a.idPublicacion where o.idPublicacion == a.idPublicacion && o.correcciones == "false" select o).ToList(); return View(); }
public ActionResult detalleuser(Guid userid) { DataClasses1DataContext db=new DataClasses1DataContext(); ViewBag.per=(from p in db.perfil where p.UserId==userid select p).ToList(); ViewBag.pub1 = (from o in db.publicacion join l in db.libro on o.idPublicacion equals l.idPublicacion where o.idPublicacion == l.idPublicacion && o.UserId == userid select o).ToList(); ViewBag.pub2 = (from p in db.publicacion join a in db.articulo on p.idPublicacion equals a.idPublicacion where p.idPublicacion == a.idPublicacion && p.UserId == userid select p).ToList(); ViewBag.pub3 = (from p1 in db.publicacion join c in db.curso on p1.idPublicacion equals c.idPublicacion where p1.idPublicacion == c.idPublicacion && p1.UserId == userid select p1).ToList(); ViewBag.pub4 = (from p2 in db.publicacion join t in db.tutorial on p2.idPublicacion equals t.idPublicacion where p2.idPublicacion == t.idPublicacion && p2.UserId == userid select p2).ToList(); ViewBag.pu = (from u in db.perfilusers where u.UserId == userid select u).ToList(); return View(); }
public void regperfilusers(perfilext model,Guid idUsers) { DataClasses1DataContext db = new DataClasses1DataContext(); perfilusers users = new perfilusers() { nombre=model.Nombre, apellido=model.Apellido, avatar=model.Avatar, ubicacion=model.Ubicacion, interes=model.Interes, UserId=idUsers }; db.perfilusers.InsertOnSubmit(users); db.SubmitChanges(); }