Пример #1
0
 public ActionResult RemoveFromWishlist(int ApplicationId, int UserId, string loc)
 {
     try
     {
         if (Session["Id"] != null)
         {
             WishlistDAO wdao = new WishlistDAO();
             Wishlist    w    = wdao.GetWishItem(UserId, ApplicationId);
             wdao.Remove(w);
             if (loc.Equals("Product"))
             {
                 return(RedirectToAction("Product", "Application", new { id = ApplicationId }));
             }
             else if (loc.Equals("Wishlist"))
             {
                 return(RedirectToAction("Wishlist", "User"));
             }
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Пример #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"));
            }
        }