public async Task <JsonResult> SendCoupon(long MemberId, long CouponId, string BillNumber = "") { var json = new JsonResult(new { }); var coupon = _Repository.FirstOrDefault(c => c.Id == CouponId); if (coupon == null) { json.Value = new { succ = false, msg = L("NotExist{0}", L("Count")) }; return(json); } if (coupon.TotalCount <= 0) { json.Value = new { succ = false, msg = L("Coupon") + L("Count") + L("NEnough") }; return(json); } coupon.TotalCount -= 1; await _Repository.UpdateAsync(coupon); CouponSendStatistics cn = new CouponSendStatistics(); cn.TenantId = coupon.TenantId; cn.CouponId = CouponId; cn.MemberId = MemberId; cn.SendOrderBillNumber = BillNumber; cn.BeginDate = DateTime.Now; cn.EndDate = DateTime.Now.AddDays(coupon.ValidityDay); await _reciveNoteAppSerivece.CreateAsync(cn); json.Value = new { succ = true }; return(json); }
public async Task CreateAsync(CouponSendStatistics dt) { await _Repository.InsertAsync(dt); }