Ejemplo n.º 1
0
        public ActionResult AddTimeProduct(TimeProductModel model)
        {
            PartProductInfo partProductInfo = AdminProducts.AdminGetPartProductById(model.Pid);

            if (partProductInfo == null)
            {
                ModelState.AddModelError("Pid", "请选择商品");
            }
            if (AdminProducts.IsExistTimeProduct(model.Pid))
            {
                ModelState.AddModelError("Pid", "此商品已经存在");
            }

            if (ModelState.IsValid)
            {
                DateTime        noTime          = new DateTime(1900, 1, 1);
                TimeProductInfo timeProductInfo = new TimeProductInfo()
                {
                    Pid          = model.Pid,
                    StoreId      = partProductInfo.StoreId,
                    OnSaleState  = model.OnSaleTime == null ? 0 : 1,
                    OutSaleState = model.OutSaleTime == null ? 0 : 1,
                    OnSaleTime   = model.OnSaleTime == null ? noTime : model.OnSaleTime.Value,
                    OutSaleTime  = model.OutSaleTime == null ? noTime : model.OutSaleTime.Value
                };
                AdminProducts.AddTimeProduct(timeProductInfo);
                AddMallAdminLog("添加定时商品", "添加定时商品,定时商品为:" + partProductInfo.Name);
                return(PromptView("定时商品添加成功"));
            }
            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
            return(View(model));
        }