コード例 #1
0
        public ActionResult Edit(Discount item)
        {
            var discount = _db.Discounts.FirstOrDefault(x => x.ID == item.ID);

            if (discount != null)
            {
                discount.Amount               = item.Amount;
                discount.Name                 = item.Name;
                discount.DiscountCode         = item.DiscountCode;
                discount.DiscountType         = item.DiscountType;
                discount.DisplayOrder         = item.DisplayOrder;
                discount.EndDate              = item.EndDate;
                discount.IsCodeRequired       = item.IsCodeRequired;
                discount.IsPercent            = item.IsPercent;
                discount.Limit                = item.Limit;
                discount.LimitType            = item.LimitType;
                discount.Percent              = item.Percent;
                discount.DiscountCartItemType = item.DiscountCartItemType;
                discount.PreventNext          = item.PreventNext;
                discount.ShopID               = item.ShopID;
                discount.StartDate            = item.StartDate;
                discount.Active               = item.Active;
                var oldProductShopIds = discount.ProductShopIDs;
                discount.ProductShopIDs = item.ProductShopIDs;

                if (oldProductShopIds != null)
                {
                    foreach (var prid in oldProductShopIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        int id   = Convert.ToInt32(prid);
                        var prod = _db.ProductShopMap.FirstOrDefault(x => x.ID == id);
                        if (prod != null)
                        {
                            prod.HaveDiscount = false;
                        }
                    }
                }

                if (discount.ProductShopIDs != null)
                {
                    foreach (var prid in discount.ProductShopIDs.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        int id   = Convert.ToInt32(prid);
                        var prod = _db.ProductShopMap.FirstOrDefault(x => x.ID == id);
                        if (prod != null)
                        {
                            prod.HaveDiscount = discount.Active;
                        }
                    }
                }

                _db.SaveChanges();
                LS.Clear <Discount>();
            }
            return(Json(new { result = "ok", discount }));
        }
コード例 #2
0
 public static void OnCreating(Discount item)
 {
     LS.Clear <Discount>();
     if (string.IsNullOrEmpty(item.ProductShopIDs))
     {
         return;
     }
     foreach (var prodShopId in item.ProductShopIDs.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
     {
         LS.Clear("discount_info_" + prodShopId);
     }
 }
 public static void CleanContentUnitMeasureMapRepository()
 {
     LS.Clear <ContentUnitMeasureMap>();
 }