public ActionResult Product(int id)
        {
            Session["prod_id"] = id;
            FichaProducto p = new FichaProducto();

            p.producto = db.PRODUCTOS.FirstOrDefault(x => x.PROD_ID == id);
            List <VALORACIONES> valoraciones = db.VALORACIONES.Where(x => x.PROD_ID == id).ToList();

            p.valoracion = valoraciones;
            try
            {
                p.prom_val = db.VALORACIONES.Where(x => x.PROD_ID == id).Average(x => x.VAL_PUNTAJE);

                //p.valoracion = db.VALORACIONES.FirstOrDefault(y => y.PROD_ID == id);
                //PRODUCTOS p = db.PRODUCTOS.FirstOrDefault(x => x.PROD_ID == id);
            }
            catch (Exception ex)
            {
            }
            if (p != null)
            {
                ViewData.Model = p;
            }
            else
            {
                ViewBag.mensaje = "Producto no encontrado";
            }
            return(View());
        }
Beispiel #2
0
 public ActionResult Valorar(FichaProducto val)
 {
     if (ModelState.IsValid)
     {
         VALORACIONES valoracion = new VALORACIONES();
         valoracion.USU_ID  = (String )Session["username"];
         valoracion.PROD_ID = (int)Session["prod_id"];
         //valoracion.VAL_COMENTARIO = comentario;
         //valoracion.VAL_PUNTAJE = puntaje;
         db.VALORACIONES.AddObject(valoracion);
         db.SaveChanges();
     }
     return(View("../Home/Product" + Session["prod_id"]));
 }