コード例 #1
0
 partial void Deletecomentario(comentario instance);
コード例 #2
0
 partial void Updatecomentario(comentario instance);
コード例 #3
0
 partial void Insertcomentario(comentario instance);
コード例 #4
0
		private void detach_comentarios(comentario entity)
		{
			this.SendPropertyChanging();
			entity.publicacion = null;
		}
コード例 #5
0
		private void detach_comentarios(comentario entity)
		{
			this.SendPropertyChanging();
			entity.aspnet_User = null;
		}
コード例 #6
0
        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");

            }
        }