コード例 #1
0
        public ResponseModel SaveManjiujian(Manjiujian model, List <string> areNum)
        {
            List <ManToArea> list = new List <ManToArea>();
            var areaHis           = _context.ManToAreas.Where(x => x.ActiveId == model.Id);

            areNum.ForEach(x =>
            {
                var area = _context.Areas.FirstOrDefault(c => c.Num == x);
                if (area != null)
                {
                    var newArea        = new ManToArea();
                    newArea.ActiveId   = model.Id;
                    newArea.ActiveName = string.Empty;
                    newArea.AreaNum    = area.Num;
                    newArea.AreaName   = area.Name;
                    list.Add(newArea);
                }
            });
            var modelHis = _context.Manjiujians.FirstOrDefault(x => x.Id == model.Id);

            modelHis.StartTime    = model.StartTime;
            modelHis.EndTime      = model.EndTime;
            modelHis.LimitMoney   = model.LimitMoney;
            modelHis.LessMoeny    = model.LessMoeny;
            modelHis.UserTypes    = model.UserTypes;
            modelHis.BrandId      = model.BrandId;
            modelHis.BrandName    = model.BrandName;
            modelHis.SupplierId   = model.SupplierId;
            modelHis.SupplierName = model.SupplierName;
            modelHis.TypeId       = model.TypeId;
            _context.ManToAreas.RemoveRange(areaHis);
            _context.ManToAreas.AddRange(list);
            _response.Stutas = _context.SaveChanges() > 0;
            return(_response);
        }        /// <summary>
コード例 #2
0
        public ResponseModel CreateCouponActivity(CouponActivity model, List <string> areNum)
        {
            List <ManToArea> list = new List <ManToArea>();
            var areaHis           = _context.ManToAreas.Where(x => x.ActiveId == model.Id);

            areNum.ForEach(x =>
            {
                var area = _context.Areas.FirstOrDefault(c => c.Num == x);
                if (area != null)
                {
                    var newArea        = new ManToArea();
                    newArea.ActiveId   = model.Id;
                    newArea.ActiveName = model.Remark;
                    newArea.AreaNum    = area.Num;
                    newArea.AreaName   = area.Name;
                    list.Add(newArea);
                }
            });

            List <string> errorNum  = new List <string>();
            var           tempModel = Utils.DeepCopyByReflect(model);

            tempModel.EffectTime = model.EffectTime;
            _context.CouponActivities.Add(tempModel);
            _context.ManToAreas.RemoveRange(areaHis);
            _context.ManToAreas.AddRange(list);

            _response.Stutas = _context.SaveChanges() > 0;
            _response.Result = errorNum;
            return(_response);
        }
コード例 #3
0
        /// <summary>
        /// 添加类目折扣
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool AddDiscountInfo(DiscountInfo info, List <string> areNum)
        {
            if (info.Id == Guid.Empty)
            {
                info.Id = Guid.NewGuid();
                var model = _context.DiscountInfos.FirstOrDefault(x => x.TypeId == info.TypeId);
                if (model != null)
                {
                    return(false);
                }
                _context.DiscountInfos.Add(info);
            }
            else
            {
                var model = _context.DiscountInfos.FirstOrDefault(x => x.Id == info.Id);
                model.StartTime = info.StartTime;
                model.EndTime   = info.EndTime;
                model.Discount  = info.Discount;
                model.UserTypes = info.UserTypes;
                model.TypeId    = info.TypeId;
                model.TypeName  = info.TypeName;
            }


            List <ManToArea> list = new List <ManToArea>();
            var areaHis           = _context.ManToAreas.Where(x => x.ActiveId == info.Id);

            areNum.ForEach(x =>
            {
                var area = _context.Areas.FirstOrDefault(c => c.Num == x);
                if (area != null)
                {
                    var newArea        = new ManToArea();
                    newArea.ActiveId   = info.Id;
                    newArea.ActiveName = string.Empty;
                    newArea.AreaNum    = area.Num;
                    newArea.AreaName   = area.Name;
                    list.Add(newArea);
                }
            });
            _context.ManToAreas.RemoveRange(areaHis);
            _context.ManToAreas.AddRange(list);

            return(_context.SaveChanges() > 0);
        }
コード例 #4
0
        /// <summary>
        /// 添加类目折扣
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool AddBlackList(BlackList info, List <string> areNum)
        {
            if (info.Id == Guid.Empty)
            {
                var goodsInfo = _context.GoodInfoes.FirstOrDefault(x => x.GoodsNum == info.GoodsNum);
                if (goodsInfo == null)
                {
                    return(false);
                }
                info.GoodsName = goodsInfo.GoodsTittle;
                info.Id        = Guid.NewGuid();
                info.GoodsId   = goodsInfo.Id;
                var model = _context.BlackLists.FirstOrDefault(x => x.GoodsId == info.GoodsId);
                if (model != null)
                {
                    return(false);
                }
                _context.BlackLists.Add(info);
            }

            List <ManToArea> list = new List <ManToArea>();
            var areaHis           = _context.ManToAreas.Where(x => x.ActiveId == info.Id);

            areNum.ForEach(x =>
            {
                var area = _context.Areas.FirstOrDefault(c => c.Num == x);
                if (area != null)
                {
                    var newArea        = new ManToArea();
                    newArea.ActiveId   = info.Id;
                    newArea.ActiveName = string.Empty;
                    newArea.AreaNum    = area.Num;
                    newArea.AreaName   = area.Name;
                    list.Add(newArea);
                }
            });
            _context.ManToAreas.RemoveRange(areaHis);
            _context.ManToAreas.AddRange(list);

            return(_context.SaveChanges() > 0);
        }
コード例 #5
0
        /// <summary>
        /// 创建满就减活动
        /// </summary>
        /// <param name="model"></param>
        /// <param name="areNum"></param>
        /// <returns></returns>
        public ResponseModel CreateManjiusong(Manjiusong model, List <string> areNum)
        {
            List <ManToArea> list = new List <ManToArea>();

            areNum.ForEach(x =>
            {
                var area = _context.Areas.FirstOrDefault(c => c.Num == x);
                if (area != null)
                {
                    var newArea        = new ManToArea();
                    newArea.ActiveId   = model.Id;
                    newArea.ActiveName = model.Tittle;
                    newArea.AreaNum    = area.Num;
                    newArea.AreaName   = area.Name;
                    list.Add(newArea);
                }
            });
            _context.ManToAreas.AddRange(list);
            _context.Manjiusongs.Add(model);
            _response.Stutas = _context.SaveChanges() > 0;
            return(_response);
        }
コード例 #6
0
        public ResponseModel SaveDPS(DPS model, List <string> areNum)
        {
            List <ManToArea> list = new List <ManToArea>();
            var areaHis           = _context.ManToAreas.Where(x => x.ActiveId == model.Id);

            areNum.ForEach(x =>
            {
                var area = _context.Areas.FirstOrDefault(c => c.Num == x);
                if (area != null)
                {
                    var newArea        = new ManToArea();
                    newArea.ActiveId   = model.Id;
                    newArea.ActiveName = model.GoodsName;
                    newArea.AreaNum    = area.Num;
                    newArea.AreaName   = area.Name;
                    list.Add(newArea);
                }
            });
            var modelHis = _context.DPSes.FirstOrDefault(x => x.Id == model.Id);

            modelHis.StartTime     = model.StartTime;
            modelHis.EndTime       = model.EndTime;
            modelHis.GoodsId       = model.GoodsId;
            modelHis.GoodsName     = model.GoodsName;
            modelHis.GoodsNum      = model.GoodsNum;
            modelHis.SendGoodsId   = model.SendGoodsId;
            modelHis.SendGoodsNum  = model.SendGoodsNum;
            modelHis.SendGoodsName = model.SendGoodsName;
            modelHis.Count         = model.Count;
            modelHis.SendCount     = model.SendCount;
            modelHis.IsOnly        = model.IsOnly;
            modelHis.IsRepeat      = model.IsRepeat;
            modelHis.UserTypes     = model.UserTypes;
            _context.ManToAreas.RemoveRange(areaHis);
            _context.ManToAreas.AddRange(list);
            _response.Stutas = _context.SaveChanges() > 0;
            return(_response);
        }