Ejemplo n.º 1
0
        public static async Task <int> SubmitZeroActivityApplicationAsync(ZeroActivityRequest requestModel, ZeroActivityDetailModel activityDetail, string userMobile)
        {
            using (var cmd = new SqlCommand(InsertZeroActivityApplication))
            {
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@Period", requestModel.Period);
                cmd.Parameters.AddWithValue("@UserID", requestModel.UserId);
                cmd.Parameters.AddWithValue("@UserName", requestModel.UserName);
                cmd.Parameters.AddWithValue("@PID", activityDetail.PID);
                cmd.Parameters.AddWithValue("@ProductName", activityDetail.ProductName);
                cmd.Parameters.AddWithValue("@Quantity", (activityDetail.NumOfWinners == 0 ? 0 : activityDetail.Quantity / activityDetail.NumOfWinners));
                cmd.Parameters.AddWithValue("@ProvinceID", requestModel.ProvinceID);
                cmd.Parameters.AddWithValue("@CityID", requestModel.CityID);
                cmd.Parameters.AddWithValue("@ApplyReason", requestModel.ApplicationReason);
                cmd.Parameters.AddWithValue("@CarID", requestModel.CarID);
                cmd.Parameters.AddWithValue("@Mobile", userMobile);
                var count = Convert.ToInt32(await DbHelper.ExecuteScalarAsync(cmd));
                if (count > 0)
                {
                    await RedisHelper.CreateZeroActivityApplyCache();

                    await RedisHelper.CreateZeroActivityApplyCacheOnPeriod(requestModel.Period);

                    await RedisHelper.CreateZeroActivityApplyCacheOnUserId(requestModel.UserId);
                }
                return(count);
            }
        }