public static PromoCode FromRpcModel(this THPromoCode rpc) { DateTime?endDate = rpc.__isset.validUntil ? DateUtils.FromUnixTime(rpc.ValidUntil) : (DateTime?)null; return(new PromoCode( code: rpc.Code, data: rpc.CustomData, maxClaimCount: (uint)rpc.MaxClaims, startDate: DateUtils.FromUnixTime(rpc.ValidFrom), endDate: endDate, creator: rpc.Creator.ToUserReference(), claimCount: (uint)rpc.NumClaims, enabled: rpc.Enabled, claimable: rpc.Claimable )); }
public static THPromoCode ToRpcModel(this PromoCodeBuilder builder) { var promoCode = new THPromoCode { Code = builder._code, MaxClaims = (int)builder._maxClaimCount, CustomData = builder._data }; if (builder._startDate != null) { promoCode.ValidFrom = builder._startDate.Value.ToUnixTimestamp(); } if (builder._endDate != null) { promoCode.ValidUntil = builder._endDate.Value.ToUnixTimestamp(); } return(promoCode); }