Ejemplo n.º 1
0
        /// <summary>
        /// 更新满减活动
        /// </summary>
        /// <param name="model"></param>
        public static void UpdateActive(FullDiscountActive model)
        {
            //  var data = Mapper.Map<FullDiscountActive, ActiveInfo>(model);
            var data = model.Map <ActiveInfo>();


            //     var rules = Mapper.Map<List<FullDiscountRules>, List<FullDiscountRuleInfo>>(model.Rules);
            var rules = model.Rules.Map <List <FullDiscountRuleInfo> >();


            //     var products = Mapper.Map<List<FullDiscountActiveProduct>, List<ActiveProductInfo>>(model.Products);
            var products = model.Products.Map <List <ActiveProductInfo> >();

            if (data.Id == 0)
            {
                throw new MallException("错误的活动编号");
            }

            //判断活动是否可添加
            if (!Service.CanOperationActive(data, products))
            {
                throw new MallException("有其他冲突活动存在,不可以完成操作");
            }

            Service.UpdateActive(data, rules, products);
        }
Ejemplo n.º 2
0
        public static void AddActive(FullDiscountActive model)
        {
            // Entities.ActiveInfo data = Mapper.Map<FullDiscountActive, Entities.ActiveInfo>(model);
            Entities.ActiveInfo data = model.Map <Entities.ActiveInfo>();


            //   List<Entities.FullDiscountRuleInfo> rules = Mapper.Map<List<FullDiscountRules>, List<Entities.FullDiscountRuleInfo>>(model.Rules);
            List <Entities.FullDiscountRuleInfo> rules = model.Rules.Map <List <Entities.FullDiscountRuleInfo> >();


            // List<Entities.ActiveProductInfo> products = Mapper.Map<List<FullDiscountActiveProduct>, List<Entities.ActiveProductInfo>>(model.Products);
            List <Entities.ActiveProductInfo> products = model.Products.Map <List <Entities.ActiveProductInfo> >();



            //判断活动是否可添加
            if (!Service.CanOperationActive(data, products))
            {
                throw new MallException("有其他冲突活动存在,不可以完成操作");
            }

            Service.AddActive(data, rules, products);
            //值回填
            model.Id = data.Id;
            foreach (var item in model.Rules)
            {
                item.ActiveId = model.Id;
            }
            foreach (var item in model.Products)
            {
                item.ActiveId = model.Id;
            }
        }