public ActionResult SetState(string ids, short state)
        {
            var sid  = ids.Split(',').Distinct();
            var list = CommodityPromotionService.FindList(o => sid.Contains(o.Id));

            list.ForEach(o => { o.State = state; });
            var re = CommodityPromotionService.Update(list);

            if (re.Successed)
            {
                var stores = string.Join(",", list.Select(o => o.StoreId).Distinct());
                Pharos.Infrastructure.Data.Redis.RedisManager.Publish("SyncDatabase", new Pharos.ObjectModels.DTOs.DatabaseChanged()
                {
                    CompanyId = Sys.SysCommonRules.CompanyId, StoreId = stores, Target = "CommodityBlendPackage"
                });
            }
            return(new JsonNetResult(re));
        }
Esempio n. 2
0
        /// <summary>
        /// 级联删除相关数据
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public static OpResult DeleteById(string[] ids)
        {
            var op = new OpResult();

            try
            {
                var promots = CommodityPromotionService.FindList(o => ids.Contains(o.Id));
                CommodityPromotionService.CurrentRepository.RemoveRange(promots, false);
                var blends = FreeGiftService.FindList(o => ids.Contains(o.CommodityId));
                FreeGiftService.CurrentRepository.RemoveRange(blends, false);
                var gifIds    = blends.Select(o => o.GiftId).Distinct().ToList();
                var repBlend  = BaseService <FreeGiftPurchaseList> .CurrentRepository;
                var blendList = repBlend.FindList(o => gifIds.Contains(o.GiftId)).ToList();
                repBlend.RemoveRange(blendList, true);
                op.Successed = true;
            }
            catch (Exception ex)
            {
                op.Message = ex.Message;
                Log.WriteError(ex);
            }
            return(op);
        }
Esempio n. 3
0
        /// <summary>
        /// 级联删除相关记录
        /// </summary>
        /// <param name="ids">主键ID</param>
        /// <returns></returns>
        public static OpResult DeleteById(string[] ids)
        {
            var op = new OpResult();

            try
            {
                var promots = CommodityPromotionService.FindList(o => ids.Contains(o.Id));
                CommodityPromotionService.CurrentRepository.RemoveRange(promots, false);
                var blends = BlendService.FindList(o => ids.Contains(o.CommodityId));
                BlendService.CurrentRepository.RemoveRange(blends, false);
                var repBlend  = BaseService <PromotionBlendList> .CurrentRepository;
                var blendList = repBlend.FindList(o => ids.Contains(o.CommodityId)).ToList();
                repBlend.RemoveRange(blendList, true);
                op.Successed = true;

                Log.WriteInfo(op.Successed ? "成功删除组合促销" : "删除组合促销失败");
            }
            catch (Exception ex)
            {
                op.Message = ex.Message;
                Log.WriteError("删除组合促销异常", ex);
            }
            return(op);
        }