public ActionResult PublicarArticulo(int id)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            var pub = db.publicacions.Where(a => a.idPublicacion == id);
            publicacion p = new publicacion() { estado = true };
            pub.ToArray()[0].estado = true;
            db.SubmitChanges();
            //cambia el estado a 1

            System.Guid idusu  = db.publicacions.Where(v=>v.idPublicacion==id).Select(i=>i.UserId).ToArray()[0];
            if (db.karmas.Where(d => d.UserId == idusu).ToList().Count == 0)
            {
                karma k = new karma() { UserId = idusu ,detalle = "puntaje  de karma", total = 10, fecha = DateTime.Now };
                db.karmas.InsertOnSubmit(k);
                db.SubmitChanges();
            }
            else {

                List<karma>   karma= db.karmas.Where(g => g.UserId == idusu).ToList();
                //kar.Sum = kar(double) + 10;
                double j = 0;
                foreach (var u in karma) {
                    double h = u.total ;
                     j = h + 10;
                }
                var l=db.karmas.Where(ll=>ll.UserId == idusu);
                karma ka = new karma() { UserId=idusu,detalle="puntaje",total = j, fecha=DateTime.Now };
                l.ToArray()[0].UserId = idusu;
                l.ToArray()[0].detalle ="puntaje";
                l.ToArray()[0].total = j;
                l.ToArray()[0].fecha = DateTime.Now;
                db.SubmitChanges();

            }

            //return View();
            return RedirectToAction("Index","ModeracionContenido");
        }
Exemplo n.º 2
0
 partial void Deletekarma(karma instance);
Exemplo n.º 3
0
 partial void Updatekarma(karma instance);
Exemplo n.º 4
0
 partial void Insertkarma(karma instance);
        public ActionResult Comentar(Comentario model, int id)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            if (Session["ids"] != null)
            {
                if (db.comentarios.Where(ss => ss.UserId == (Guid)Session["ids"]).Where(tt => tt.infraccion == 1).ToList().Count <= 3)
                {
                    System.Guid idusu = (Guid)Session["ids"];
                    string[] arraycomentario = model.Descripcion.ToLower().Split(' ');
                    List<diccionario> malaspalabras = new List<diccionario>();
                    foreach (var items in arraycomentario)
                    {
                        string item = items.Trim();
                        if (db.diccionarios.Where(x => x.palabra == item).Count() != 0)
                        {
                            foreach (var ii in db.diccionarios)
                            {
                                if (ii.palabra == item)
                                {
                                    malaspalabras.Add(new diccionario() { palabra = item });
                                }
                            }
                        }
                    }
                    if (malaspalabras.ToList().Count() > 0)
                    {

                        comentario a = new comentario() { UserId = idusu, idPublicacion = id, Descripcion = model.Descripcion, puntuacion = 0.5, fecha = DateTime.Now, infraccion = 1 };
                        db.comentarios.InsertOnSubmit(a);
                        db.SubmitChanges();
                    }
                    else
                    {
                        comentario a = new comentario() { UserId = idusu, idPublicacion = id, Descripcion = model.Descripcion, puntuacion = 0.5, fecha = DateTime.Now, infraccion = 0 };
                        db.comentarios.InsertOnSubmit(a);
                        db.SubmitChanges();
                    }
                    //actualiza su karma
                    if (db.karmas.Where(d => d.UserId == idusu).ToList().Count == 0)
                    {
                        karma k = new karma() { UserId = idusu, detalle = "puntaje  de karma", total = 0.5, fecha = DateTime.Now };
                        db.karmas.InsertOnSubmit(k);
                        db.SubmitChanges();
                    }
                    else
                    {
                        List<karma> karma = db.karmas.Where(g => g.UserId == idusu).ToList();
                        //kar.Sum = kar(double) + 10;
                        double j = 0;
                        foreach (var u in karma)
                        {
                            double h = u.total;
                            j = h + 0.5;
                        }
                        var l = db.karmas.Where(ll => ll.UserId == idusu);
                        karma ka = new karma() { UserId = idusu, detalle = "puntaje", total = j, fecha = DateTime.Now };
                        l.ToArray()[0].UserId = idusu;
                        l.ToArray()[0].detalle = "puntaje";
                        l.ToArray()[0].total = j;
                        l.ToArray()[0].fecha = DateTime.Now;
                        db.SubmitChanges();

                    }
                    int i = id;
                    if (db.libros.Where(v => v.idPublicacion == i).ToList().Count != 0)
                    {
                        return RedirectToAction("Vlibro", "Home", new { id = id });
                    }
                    if (db.cursos.Where(v => v.idPublicacion == i).ToList().Count != 0)
                    {
                        return RedirectToAction("Vcurso", "Home", new { id = id });
                    }
                    if (db.articulos.Where(v => v.idPublicacion == i).ToList().Count != 0)
                    {
                        return RedirectToAction("Varticulo", "Home", new { id = id });

                    }
                    if (db.tutorials.Where(v => v.idPublicacion == i).ToList().Count != 0)
                    {
                        return RedirectToAction("Vtutorial", "Home", new { id = id });

                    }

                    return RedirectToAction("Index", "Home");

                }
                else
                {
                    System.Guid IdUs = db.aspnet_Users.Where(a => a.UserId == (Guid)Session["ids"]).Select(a => a.UserId).ToArray()[0];
                    System.Guid IdRol = db.aspnet_Roles.Where(a => a.RoleName == "vaneado").Select(a => a.RoleId).ToArray()[0];
                    //elimina la fila relacion
                    aspnet_UsersInRole v = db.aspnet_UsersInRoles.Where(n => n.UserId == IdUs).ToArray()[0];
                    db.aspnet_UsersInRoles.DeleteOnSubmit(v);
                    db.SubmitChanges();

                    //agrega la nueva relacion de usuario vaneado
                    var vane = db.aspnet_UsersInRoles.Where(f => f.UserId == IdUs);
                    aspnet_UsersInRole rel = new aspnet_UsersInRole() { RoleId = IdRol, UserId = IdUs };
                    db.aspnet_UsersInRoles.InsertOnSubmit(rel);
                    db.SubmitChanges();

                    ViewBag.Message = "UD A SIDO BANEADO DEL SISTEMA POR REALIZAR COMENTARIOS ABUSIVOS";
                    return RedirectToAction("LogOn", "Account");
                }
            }
            else
            {
                ViewBag.Message = "DEBE ESTAR REGISTRADO";
                return RedirectToAction("LogOn", "Account");

            }
        }
        public ActionResult megusta(int id)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            if ((Guid)Session["ids"] != null)
            {
                if (db.karma2s.Where(g => g.UserId == (Guid)Session["ids"]).ToList().Count() == 0)
                {
                    ViewBag.id = id;
                    System.Guid idus = (Guid)Session["ids"];
                    if (db.karmas.Where(g => g.UserId == (Guid)Session["ids"]).ToList().Count() == 0)
                    {
                        karma kk = new karma() { UserId = idus, detalle = "puntajes de karma", total = 1, fecha = DateTime.Now };
                        db.karmas.InsertOnSubmit(kk);
                        db.SubmitChanges();
                        ViewBag.estado = 1;
                        karma2 k = new karma2() { UserId = idus, idPublicacion = id };
                        db.karma2s.InsertOnSubmit(k);
                        db.SubmitChanges();
                    }
                    else
                    {
                        List<karma> karma = db.karmas.Where(g => g.UserId == idus).ToList();
                        double j = 0;
                        foreach (var u in karma)
                        {
                            double h = u.total;
                            j = h + 1;
                        }
                        var l = db.karmas.Where(ll => ll.UserId == idus);
                        karma ka = new karma() { UserId = idus, detalle = "puntaje", total = j, fecha = DateTime.Now };
                        l.ToArray()[0].UserId = idus;
                        l.ToArray()[0].detalle = "puntaje";
                        l.ToArray()[0].total = j;
                        l.ToArray()[0].fecha = DateTime.Now;
                        db.SubmitChanges();
                        ViewBag.estado = 1;
                        karma2 k = new karma2() { UserId = idus, idPublicacion = id };
                        db.karma2s.InsertOnSubmit(k);
                        db.SubmitChanges();
                    }
                    int i = id;
                    if (db.libros.Where(v => v.idPublicacion == i).ToList().Count() != 0)
                    {
                        return RedirectToAction("Vlibro", "Home", new { id = id });
                    }
                    if (db.cursos.Where(v => v.idPublicacion == i).ToList().Count() != 0)
                    {
                        return RedirectToAction("Vcurso", "Home", new { id = id });
                    }
                    if (db.articulos.Where(v => v.idPublicacion == i).ToList().Count() != 0)
                    {
                        return RedirectToAction("Varticulo", "Home", new { id = id });
                    }
                    if (db.tutorials.Where(v => v.idPublicacion == i).ToList().Count() != 0)
                    {
                        return RedirectToAction("Vtutorial", "Home", new { id = id });
                    }
                }
                else
                {
                    ViewBag.estado = 0;
                    ViewBag.id = id;
                    System.Guid idus = (Guid)Session["ids"];
                    List<karma> karma = db.karmas.Where(g => g.UserId == idus).ToList();
                    double j = 0;
                    foreach (var u in karma)
                    {
                        double h = u.total;
                        j = h - 1;
                    }
                    var l = db.karmas.Where(ll => ll.UserId == idus);
                    karma k = new karma() { UserId = idus, detalle = "puntaje", total = j, fecha = DateTime.Now };
                    l.ToArray()[0].UserId = idus;
                    l.ToArray()[0].detalle = "puntaje";
                    l.ToArray()[0].total = j;
                    l.ToArray()[0].fecha = DateTime.Now;
                    db.SubmitChanges();
                    karma2 bk = db.karma2s.Where(r => r.UserId == idus).ToArray()[0];
                    db.karma2s.DeleteOnSubmit(bk);
                    db.SubmitChanges();

                    int i = id;
                    if (db.libros.Where(v => v.idPublicacion == i).ToList().Count() != 0)
                    {
                        return RedirectToAction("Vlibro", "Home", new { id = id });
                    }
                    if (db.cursos.Where(v => v.idPublicacion == i).ToList().Count() != 0)
                    {
                        return RedirectToAction("Vcurso", "Home", new { id = id });
                    }
                    if (db.articulos.Where(v => v.idPublicacion == i).ToList().Count() != 0)
                    {
                        return RedirectToAction("Varticulo", "Home", new { id = id });
                    }
                    if (db.tutorials.Where(v => v.idPublicacion == i).ToList().Count() != 0)
                    {
                        return RedirectToAction("Vtutorial", "Home", new { id = id });
                    }
                }
            }
            else
            {
                return RedirectToAction("LogOn","Account");
            }
            return RedirectToAction("Index","Home");
        }