Exemplo n.º 1
0
 partial void Deletekarma2(karma2 instance);
Exemplo n.º 2
0
 partial void Updatekarma2(karma2 instance);
Exemplo n.º 3
0
 partial void Insertkarma2(karma2 instance);
Exemplo n.º 4
0
		private void detach_karma2s(karma2 entity)
		{
			this.SendPropertyChanging();
			entity.publicacion = null;
		}
Exemplo n.º 5
0
		private void detach_karma2s(karma2 entity)
		{
			this.SendPropertyChanging();
			entity.aspnet_User = null;
		}
        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");
        }