private void ShowMyPromoCode()
 {
     if (GetSocial.GetCurrentUser().PrivateProperties.ContainsKey(MyPromoCodeKey))
     {
         ShowPromoCode(GetSocial.GetCurrentUser().PrivateProperties[MyPromoCodeKey]);
     }
     else
     {
         PromoCodes.Create(PromoCodeContent.CreateRandomCode().AddProperty(MyPromoCodeKey, "true"), promoCode => {
             var userUpdate = new UserUpdate().AddPrivateProperty(MyPromoCodeKey, promoCode.Code);
             GetSocial.GetCurrentUser().UpdateDetails(userUpdate, ShowMyPromoCode,
                                                      error => _console.LogE(string.Format("Failed to set private property: {0}", error.Message), showImmediately: false));
         }, error => _console.LogE(string.Format("Failed to create promo code: {0}", error.Message), showImmediately: false));
     }
 }
    private void DrawCreatePromoCodeBody()
    {
        GUILayout.Label("Promo code(leave empty for random): ", GSStyles.NormalLabelText);
        _code = GUILayout.TextField(_code, GSStyles.TextField);

        GUILayout.Label("Max Claim Count(0 or empty for unlim): ", GSStyles.NormalLabelText);
        _maxClaimCount = GUILayout.TextField(_maxClaimCount, GSStyles.TextField);
        _maxClaimCount = Regex.Replace(_maxClaimCount, @"[^0-9]", "");

        GUILayout.Label("Start date('dd/MM/yyyy HH:mm:ss' or 'dd/MM/yyy'): ", GSStyles.NormalLabelText);
        _startDate = GUILayout.TextField(_startDate, GSStyles.TextField);

        GUILayout.Label("End date('dd/MM/yyyy HH:mm:ss' or 'dd/MM/yyy'): ", GSStyles.NormalLabelText);
        _endDate = GUILayout.TextField(_endDate, GSStyles.TextField);

        DemoGuiUtils.DynamicRowFor(_data, "Custom data");

        DemoGuiUtils.DrawButton("Create", () => {
            if (_loading)
            {
                return;
            }
            _loading      = true;
            var promoCode = (_code == null || _code.Length > 0 ? PromoCodeContent.CreateWithCode(_code) : PromoCodeContent.CreateRandomCode());
            promoCode.AddProperties(_data.ToDictionary(data => data.Key, data => data.Val));
            promoCode.MaxClaimCount = Convert.ToUInt32(_maxClaimCount);
            var startDate           = ParseDate(_startDate);
            var endDate             = ParseDate(_endDate);
            if (startDate.HasValue && endDate.HasValue)
            {
                Debug.LogFormat("{0} => {1}", startDate, endDate);
                promoCode.SetTimeLimit(startDate.Value, endDate.Value);
            }
            PromoCodes.Create(promoCode,
                              code => {
                _loading = false;
                ShowFullInfoWithoutActions(code);
            }, error => {
                _loading = false;
                _console.LogE(string.Format("Failed to create promo code: {0}", error.Message));
            }
                              );
        }, style: GSStyles.Button);

        DemoGuiUtils.DrawButton("Back", () => {
            _createPromoCode = false;
        }, style: GSStyles.Button);
    }