shzxscmvc/Controllers/CartController.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using shzxscmvc.Models;
namespace shzxscmvc.Controllers
{
    public class CartController : Controller
    {
        //
        // GET: /Cart/
        shzxscentiti shdb = new shzxscentiti();
        shoppingcart spct = new shoppingcart();
        const string PromoCode = "FREE";

        public RedirectToRouteResult AddToCart( int Id, string returnUrl, string assess, int svol)
        {
            var cart = shoppingcart.GetCart();
            goods goods = shdb.goods
                    .FirstOrDefault(g => g.Id == Id);
           if (goods != null)
            {
                cart.AddItem(Id, assess, svol);
            }
            return RedirectToAction("Index", new { returnUrl });
        }

        public RedirectToRouteResult RemoveFromCart(int goodsId, string returnUrl)
        {
            var cart = shoppingcart.GetCart();
            goods goods = shdb.goods
                        .FirstOrDefault(g => g.Id ==goodsId);

            if (goods != null)
            {
                cart.RemoveLine(goodsId);
            }
            return RedirectToAction("Index", new { returnUrl });
        }


        public ViewResult Index(string returnUrl)
        {
            var cart = shoppingcart.GetCart();
            var viewModel = new CartIndexViewModel
            {                
                CartItems = cart.GetCartItems(),
                CartTotal = cart.GetTotal(),
                ReturnUrl = returnUrl
            };
            return View(viewModel);
        }
        [ChildActionOnly]
        public ActionResult CartSummary()
        {
            var cart = shoppingcart.GetCart();
            ViewData["CartCount"] = cart.GetCount();
            return PartialView("CartSummary");
        }
后面还有 62 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。