Beispiel #1
0
        public static PromotionModel GetPromotionDetail(int id)
        {
            var dt = DALPromotion.GetPromotionDetail(id);

            if (dt == null || dt.Rows.Count <= 0)
            {
                return(new PromotionModel());
            }
            var result = dt.Rows.Cast <DataRow>().Select(row => new PromotionModel(row)).FirstOrDefault();

            var proConfig  = DALPromotion.GetCouponProductConfig(result.PKID);
            var shopConfig = DALPromotion.GetCouponShopConfig(result.PKID);

            result.ShopConfig     = shopConfig.Rows.Cast <DataRow>().Select(row => new CouponRulesConfigShop(row)).ToList();
            result.ProductsConfig = proConfig.Rows.Cast <DataRow>().Select(row => new CouponRulesConfigProduct(row)).ToList();
            var pids = result.ProductsConfig.Where(x => x.Type == 4).Select(x => x.ConfigValue).ToList();

            if (pids.Any())
            {
                IAutoSuppliesManager manager = new AutoSuppliesManager();
                var names = manager.GetProductNamesByPids(pids);
                foreach (var p in result.ProductsConfig)
                {
                    if (p.Type == 4 && names.ContainsKey(p.ConfigValue))
                    {
                        p.ProductName = names[p.ConfigValue];
                    }
                }
            }

            return(result);
        }
Beispiel #2
0
        public ActionResult Edit(OrderAreaProduct product)
        {
            //查询产品Id是否存在
            var resultData = AutoSuppliesManager.GetProductInfoByPIdNewVersion(product.PId);

            if (resultData == null)
            {
                ViewBag.Result = "您输入的产品Id不存在.";
                return(View());
            }
            //1.先查询数据是否存在
            //2. 如果不存在,直接跳转到HomePageConfig/Index页面
            if (product != null)
            {
                if (OrderAreaProductManager.HasSingleProduct(product.Id))
                {
                    ViewBag.Result = OrderAreaProductManager.UpdateOrderAreaProduct(product);
                }
                else
                {
                    return(RedirectToAction("Index", "OrderArea"));
                }
            }

            return(RedirectToAction("SearchProductsByMoudleId", new { id = product.OrderAreaId }));
        }
Beispiel #3
0
        public ActionResult Add(OrderAreaProduct product, int id)
        {
            var resultData = AutoSuppliesManager.GetProductInfoByPIdNewVersion(product.PId);

            if (resultData == null)
            {
                ViewBag.Result = "您输入的产品Id不存在.";
                return(View());
            }

            if (product != null)
            {
                // 设置上一个请求传递过来的appsetDataid
                product.OrderAreaId = id;
                ViewBag.Result      = OrderAreaProductManager.AddOrderAreaProduct(product);
            }

            return(RedirectToAction("SearchProductsByMoudleId", new { id = id }));
        }
Beispiel #4
0
 public ActionResult GetProductById(string pid)
 {
     try
     {
         if (string.IsNullOrEmpty(pid))
         {
             return(Content("-1"));
         }
         var resultData = AutoSuppliesManager.GetProductInfoByPIdNewVersion(pid);
         if (resultData != null)
         {
             return(Content(JsonConvert.SerializeObject(resultData, new DataTableConverter())));
         }
         else
         {
             return(Content("-1"));
         }
     }
     catch (Exception)
     {
         return(Content("-1"));
     }
 }