示例#1
0
        public IHttpActionResult CreateCoupon([FromBody] Coupons data)
        {
            CouponsService service = new CouponsService();

            service.CouponsCreate(data);
            return(Ok(data));
        }
示例#2
0
        public IHttpActionResult DeleteCoupon([FromBody] Guid id)
        {
            CouponsService service = new CouponsService();

            service.DeleteConfirmed(id);
            return(Ok(id));
        }
示例#3
0
        public IHttpActionResult SaveEditCoupon([FromBody] Coupons data)
        {
            CouponsService service = new CouponsService();

            service.CouponsEdit(data);
            return(Ok(data));
        }
示例#4
0
        public IMessageProvider Save()
        {
            var item = CouponsService.GetById(Id);

            if (item != null)
            {
                item.name             = this.name;
                item.discount         = this.discount;
                item.deductibleAmount = this.deductibleAmount;
                item.fullAmount       = this.fullAmount;
                item.reduceAmount     = this.reduceAmount;
                item.quantity         = this.quantity;
                if (Shop.Key == Globals.All)
                {
                    item.useScope = "";
                }
                else
                {
                    var shop = ShopService.GetById(Shop.Key);
                    if (shop != null)
                    {
                        item.useScope = shop.Name;
                    }
                    else
                    {
                        AddError(LogTypes.CouponEdit, "商户不存在");
                        return(this);
                    }
                }
                item.validity    = this.validity;
                item.couponsType = CouponType.Key;
                CouponsService.Update(item);
                Logger.LogWithSerialNo(LogTypes.CouponEdit, item.name, InnerObject.id, item);
            }
            AddMessage("success", item.name);
            SetInnerObject(item);
            Ready();
            if (string.IsNullOrWhiteSpace(item.useScope))
            {
                Shop.Key = Globals.All;
            }
            else
            {
                var shop = ShopService.GetByName(item.useScope);
                if (shop != null)
                {
                    Shop.Key = shop.ShopId;
                }
                else
                {
                    Shop.Key = Globals.All;
                }
            }

            return(this);
        }
示例#5
0
        public void Read(int id)
        {
            var item = CouponsService.GetById(id);

            if (item != null)
            {
                SetInnerObject(item);
            }
            Ready();
            Shop.Key = item.id;
        }
示例#6
0
        public IMessageProvider Save()
        {
            var model = new Coupons();

            model.code             = DateTime.Now.ToString("yyyyMMddHHmmssffff");
            model.name             = this.name;
            model.state            = CouponsState.Invalid;
            model.createOp         = SecurityHelper.GetCurrentUser().CurrentUser.Name;
            model.createTime       = DateTime.Now;
            model.discount         = this.discount;
            model.deductibleAmount = this.deductibleAmount;
            model.fullAmount       = this.fullAmount;
            model.reduceAmount     = this.reduceAmount;
            model.leadersOfNum     = 0;
            model.quantity         = this.quantity;
            if (Shop.Key == Globals.All)
            {
                model.useScope = "";
            }
            else
            {
                var shop = ShopService.GetById(Shop.Key);
                if (shop != null)
                {
                    model.useScope = shop.Name;
                }
                else
                {
                    AddError(LogTypes.CouponCreate, "商户不存在");
                    return(this);
                }
            }
            model.validity    = this.validity;
            model.couponsType = CouponType.Key;
            CouponsService.Create(model);
            AddMessage("success", model.name);
            Logger.LogWithSerialNo(LogTypes.CouponCreate, model.name, InnerObject.id, model);
            return(this);
        }
示例#7
0
        public List <Coupons> GetCoupons()
        {
            CouponsService service = new CouponsService();

            return(service.GetAllCoupons());
        }