Exemplo n.º 1
0
 public ActionResult Product(int id)
 {
     try
     {
         ApplicationDAO dao   = new ApplicationDAO();
         DeveloperDAO   ddao  = new DeveloperDAO();
         ImageDAO       idao  = new ImageDAO();
         UserDAO        udao  = new UserDAO();
         SellItemDAO    sidao = new SellItemDAO();
         Application    app   = dao.SearchById(id);
         Developer      dev   = ddao.SearchById(app.DeveloperId);
         CartDAO        cdao  = new CartDAO();
         PegiDAO        pdao  = new PegiDAO();
         ViewBag.SellItem = false;
         if (Session["Id"] != null)
         {
             ViewBag.Cart     = cdao.SearchCartUser(int.Parse(Session["Id"].ToString()));
             ViewBag.SellItem = sidao.SearchUserApp(int.Parse(Session["Id"].ToString()), id);
             WishlistDAO wdao = new WishlistDAO();
             ViewBag.IsInWish = wdao.IsInWishList(int.Parse(Session["Id"].ToString()), id);
         }
         ViewBag.App     = app;
         ViewBag.Dev     = dev;
         ViewBag.Pegi    = pdao.SearchById(app.PegiId);
         ViewBag.DevUser = udao.SearchByDev(dev.Id);
         ViewBag.Img     = idao.SearchAppImages(id);
         ViewBag.Similar = dao.ListLast10();
         return(View());
     }
     catch
     {
         return(RedirectToAction("../Home/Index"));
     }
 }
Exemplo n.º 2
0
 public ActionResult AddToWishlist(int ApplicationId, int UserId)
 {
     try
     {
         if (Session["Id"] != null)
         {
             WishlistDAO wdao = new WishlistDAO();
             Wishlist    w    = new Wishlist();
             w.ApplicationId = ApplicationId;
             w.UserId        = UserId;
             if (!wdao.IsInWishList(w.UserId, w.ApplicationId))
             {
                 wdao.Add(w);
             }
             return(RedirectToAction("Product", "Application", new { id = ApplicationId }));
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }