Esempio n. 1
0
        public void CreateOrUpdateCoupon(IMCode mcode, JObject body)
        {
            Guard.ArgumentNotNull(mcode, "mcode");
            Guard.ArgumentNotNull(body, "body");

            var merchant = sharingHostService.MerchantDetails.FirstOrDefault(o => o.MCode.Equals(mcode.MCode));

            Guard.ArgumentNotNull(merchant, "merchant");

            var official = merchant.Apps.FirstOrDefault(o => o.AppType == AppTypes.Official);

            Guard.ArgumentNotNull(official, "official");
            var result = this.wxapi.SaveOrUpdateCardCoupon(official, body);

            if (result.HasError == false)
            {
                this.mCardService.WriteIntoDatabase(new List <MCard>()
                {
                    body.ParseMCard(merchant.Id, result.CardId)
                });
            }
        }
Esempio n. 2
0
 public static IWxApp ChooseMiniprogram(this IEnumerable <MerchantDetails> details, IMCode mcode)
 {
     return(details.Where(o => o.MCode.Equals(mcode.MCode))
            .SelectMany(o => o.Apps)
            .FirstOrDefault(o => o.AppType == AppTypes.Miniprogram));
 }