Ejemplo n.º 1
0
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> AddCart()
        {
            string userId = User.Identity.GetUserId();
            string bookId = HttpContext.Request["bookId"];

            using (var context = new OnionContext())
            {
                PREORDER preOrder = context.preorders.Find(userId, bookId);
                if (preOrder == null)
                {
                    preOrder = new PREORDER()
                    {
                        CUSTOMERID = userId,
                        BOOKID     = bookId,
                        AMOUNT     = 1,
                    };
                    context.preorders.Add(preOrder);
                }
                else
                {
                    preOrder.AMOUNT += 1;
                }


                int x = await(context.SaveChangesAsync());
            }
            return(Content("添加成功"));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> RemoveStar()
        {
            string userId = User.Identity.GetUserId();
            string bookId = HttpContext.Request["bookId"];

            using (var context = new OnionContext())
            {
                var s = context.stars.Find(userId, bookId);
                context.stars.Remove(s);
                await context.SaveChangesAsync();
            }
            return(Content("删除成功"));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> RemoveCart()
        {
            string userId    = User.Identity.GetUserId();
            string bookId    = HttpContext.Request["bookId"];
            string returnURL = HttpContext.Request["returnUrl"];

            using (var context = new OnionContext())
            {
                var pre = context.preorders.Find(userId, bookId);
                context.preorders.Remove(pre);
                await context.SaveChangesAsync();
            }
            return(Redirect(returnURL));
        }