/// <summary>
        /// 根据优惠券id获取  一分钱洗车优惠券领取记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static async Task <OperationResult <WashCarCouponRecordModel> > GetWashCarCouponInfoByPromotionCodeIDAsync(GetWashCarCouponInfoByPromotionCodeIDRequest request)
        {
            WashCarCouponRecordModel models = new WashCarCouponRecordModel();

            try
            {
                var result = await DalWashCarCouponRecord.GetWashCarCouponListByPromotionCodeIDAsync(request.PromotionCodeID);

                models = ObjectMapper.ConvertTo <WashCarCouponRecordEntity, WashCarCouponRecordModel>(result).FirstOrDefault();
                return(OperationResult.FromResult(models));
            }
            catch (Exception ex)
            {
                return(OperationResult.FromError <WashCarCouponRecordModel>("500", ex.Message));
            }
        }
 public void CreateWashCarCouponAsync()
 {
     using (var client = new WashCarCouponClient())
     {
         WashCarCouponRecordModel request = new WashCarCouponRecordModel()
         {
             UserID          = Guid.Parse("FEEF7C6D-B5B6-41C8-8108-76596514A511"),
             CarID           = Guid.Empty,
             CarNo           = "贵CV1000",
             VehicleID       = "VE-GM-S07BTHRV",
             Vehicle         = "凯越HRV-上海通用别克",
             PaiLiang        = "1.6L",
             Nian            = "2013",
             Tid             = "Tid",
             PromotionCodeID = 10,
         };
         var result = client.CreateWashCarCoupon(request);
         Assert.IsNotNull(result.Result);
     }
 }
        /// <summary>
        ///  新增 一分钱洗车优惠券领取记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static async Task <OperationResult <bool> > CreateWashCarCouponAsync(WashCarCouponRecordModel request)
        {
            try
            {
                #region 新增时 数据验证
                string validMSG = "";
                if (request == null)
                {
                    validMSG = "请求参数不能为空";
                }
                else if (string.IsNullOrWhiteSpace(request.CarNo))
                {
                    validMSG = "车牌号不能为空";
                }
                else if (Guid.Empty == request.UserID)
                {
                    validMSG = "用户不能为空";
                }
                else if (request.PromotionCodeID <= 0)
                {
                    validMSG = "优惠券不能为空";
                }
                if (!string.IsNullOrWhiteSpace(validMSG))
                {
                    return(OperationResult.FromError <bool>("-1", validMSG));
                }
                #endregion
                WashCarCouponRecordEntity entity = ObjectMapper.ConvertTo <WashCarCouponRecordModel, WashCarCouponRecordEntity>(request);
                var result = await DalWashCarCouponRecord.CreateWashCarCouponAsync(entity);

                return(OperationResult.FromResult(result > 0));
            }
            catch (Exception ex)
            {
                return(OperationResult.FromError <bool>("500", ex.Message));
            }
        }