public IHttpActionResult CreateCoupon([FromBody] Coupons data) { CouponsService service = new CouponsService(); service.CouponsCreate(data); return(Ok(data)); }
public IHttpActionResult DeleteCoupon([FromBody] Guid id) { CouponsService service = new CouponsService(); service.DeleteConfirmed(id); return(Ok(id)); }
public IHttpActionResult SaveEditCoupon([FromBody] Coupons data) { CouponsService service = new CouponsService(); service.CouponsEdit(data); return(Ok(data)); }
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); }
public void Read(int id) { var item = CouponsService.GetById(id); if (item != null) { SetInnerObject(item); } Ready(); Shop.Key = item.id; }
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); }
public List <Coupons> GetCoupons() { CouponsService service = new CouponsService(); return(service.GetAllCoupons()); }