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 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 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 corregidot(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 = "true"; karma.karma += 50; db.SubmitChanges(); } return Redirect("/modcontenido/mod"); }
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 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 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(); }
public void regroles(Guid idus,Guid idrol) { DataClasses1DataContext db = new DataClasses1DataContext(); aspnet_UsersInRoles roles = new aspnet_UsersInRoles() { UserId=idus, RoleId=idrol }; db.aspnet_UsersInRoles.InsertOnSubmit(roles); db.SubmitChanges(); }
public ActionResult eliminarcomet(int id) { using(DataClasses1DataContext db=new DataClasses1DataContext()){ ViewBag.p=(from c in db.comentarios where c.idComentarios==id select c).ToList(); //comentarios Delete = db.comentarios.Single(p => p.idPublicacion == id); foreach(var del in ViewBag.p) db.comentarios.DeleteOnSubmit(del); db.SubmitChanges(); } DataClasses1DataContext db1 = new DataClasses1DataContext(); var s = (from m in db1.mode_coment select m.idpublicacion).Min(); return RedirectToAction("coment1","coment"); }
public ActionResult nomegusta(int id) { using (DataClasses1DataContext db = new DataClasses1DataContext()) { var pl = (from p in db.publicacion where p.idPublicacion == id select p).Single(); pl.puntaje -= 1; db.SubmitChanges(); } return Redirect("http://localhost:4391/Home/About/"+id); }
public ActionResult megusta(int id) { using (DataClasses1DataContext db = new DataClasses1DataContext()) { Guid iid=(Guid)Membership.GetUser().ProviderUserKey; var pl=(from p in db.publicacion where p.idPublicacion==id select p).Single(); var per=(from pp in db.perfil where pp.UserId==iid select pp).Single(); pl.puntaje += 1; per.karma += 1; db.SubmitChanges(); } return Redirect("http://localhost:4391/Home/About/"+id); }