Example #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"));
     }
 }
Example #2
0
        public ActionResult Sell()
        {
            try
            {
                CartDAO      cdao = new CartDAO();
                IList <Cart> cart = cdao.GetUserCart(int.Parse(Session["Id"].ToString()));
                if (Session["Id"] != null && cart.Count() != 0)
                {
                    SellDAO dao = new SellDAO();
                    Sell    s   = new Sell();
                    s.UserId     = int.Parse(Session["Id"].ToString());
                    s.Date       = DateTime.Now;
                    s.TotalPrice = cdao.GetSubtotal(s.UserId);
                    dao.Add(s);
                    foreach (var c in cart)
                    {
                        SellItemDAO sidao = new SellItemDAO();
                        SellItem    si    = new SellItem();
                        si.ApplicationId = c.ApplicationId;
                        si.PriceItem     = c.Price;
                        si.SellId        = s.Id;
                        sidao.Add(si);
                        cdao.Remove(c);

                        //Removing from Wishlist
                        WishlistDAO      wdao  = new WishlistDAO();
                        IList <Wishlist> wishs = wdao.GetUserList(int.Parse(Session["Id"].ToString()));
                        foreach (var w in wishs)
                        {
                            if (w.ApplicationId == c.ApplicationId)
                            {
                                wdao.Remove(w);
                            }
                        }
                    }
                    return(RedirectToAction("Library", "User"));
                }
                else
                {
                    return(RedirectToAction("../Home/Index"));
                }
            }
            catch
            {
                return(RedirectToAction("../Home/Index"));
            }
        }
Example #3
0
 public ActionResult Library()
 {
     try
     {
         if (Session["Id"] != null)
         {
             CartDAO          cardao = new CartDAO();
             SellItemDAO      sidao  = new SellItemDAO();
             SellDAO          sdao   = new SellDAO();
             ApplicationDAO   appdao = new ApplicationDAO();
             IList <SellItem> si     = sidao.GetUserApps(int.Parse(Session["Id"].ToString()));
             ViewBag.UserApps  = si;
             ViewBag.AppsinLib = appdao.GetAppsInLibrary(si);
             ViewBag.Sells     = sdao.GetUserSells(int.Parse(Session["Id"].ToString()));
             ViewBag.Cart      = cardao.SearchCartUser(int.Parse(Session["Id"].ToString()));
             return(View());
         }
         return(RedirectToAction("../Home/Index"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }