public HttpResponseMessage SetCouponList([FromBody] CC_Coupon couponData) { try { var db = new RedisOperation(_RedisDB); var key = RedisKeys.CCCouponKey(couponData.CustomerId, couponData.CouponTypeId); // var coupons = new List <CC_Coupon>(); for (var i = 0; i < couponData.CouponLenth; i++) { coupons.Add(couponData.DeepClone()); } // var total = couponData.CouponLenth; var limit = 100; var start = 0; // do { // var models = coupons.Skip(start).Take(limit).ToList(); // db.InsertListQueueBatch <CC_Coupon>(key, models); // if (start < (total - limit)) { start = start + limit; } else { start = total; } }while (start < total); return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.Success, Message = "success" })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.Fail, Message = "fail:" + ex.Message })); } }
public HttpResponseMessage DeleteCouponList([FromBody] CC_Coupon couponData) { try { var db = new RedisOperation(_RedisDB); var key = RedisKeys.CCCouponKey(couponData.CustomerId, couponData.CouponTypeId); var result = db.Delete(key); return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.Success, Message = "success" })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new ResponseModel { Code = ResponseCode.Fail, Message = "fail:" + ex.Message })); } }