Пример #1
0
        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
                }));
            }
        }
Пример #2
0
 public HttpResponseMessage SetPrizePools([FromBody] List <CC_PrizePool> prizePoolData)
 {
     try
     {
         var db  = new RedisOperation(_RedisDB);
         var key = RedisKeys.CCPrizePoolsKey(prizePoolData.FirstOrDefault().CustomerId, prizePoolData.FirstOrDefault().EventId);
         //db.InsertListQueue(key, prizePoolData);
         db.InsertListQueueBatch(key, prizePoolData);
         db.Expire(TimeSpan.FromHours(prizePoolData.FirstOrDefault().ValidHours), 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
         }));
     }
 }