示例#1
0
        private async void Initialize()
        {
            if (IsBusy || IsLoading)
            {
                // Message toast
                ShowSnackBarWithAction(TranslateManagerHelper.Convert("loading_please_wait"), null, TranslateManagerHelper.Convert("ok").ToUpperInvariant());
                return;
            }
            IsLoading = true;

            Items = new ObservableCollection <VoucherModel>();

            var response = await _applicationsService.GetApplicationUserVouchers(_authentication.GetToken(), (long)_appInfo?.App?.Id, _userInformation.UserId);

            if (response != null && response?.isuccess == true)
            {
                foreach (var item in response.data)
                {
                    Items.Add(new VoucherModel
                    {
                        Amount        = item.Value.ToString(),
                        Id            = item.Id,
                        CurrencyId    = item.CurrencyId,
                        QrCode        = item.QrCode,
                        Currency      = item.CurrencyCode,
                        VoucherNumber = item.Number,
                        Icon          = ""
                    });
                }
            }
            else
            {
                string message;
                switch (response?.errcode)
                {
                case "EXCEPTION":
                    message = TranslateManagerHelper.Convert("operation_failed");
                    break;

                default:
                    message = !string.IsNullOrEmpty(response?.msg) ? response?.msg : TranslateManagerHelper.Convert("error_occured");
                    break;
                }

                var parameters = new NavigationParameters
                {
                    { Constants.PopupIsSucces, false },
                    { Constants.PopupIsBeforeHome, false },
                    { Constants.PopupMessage, message },
                    { Constants.PopupNextPage, "" }
                };
                await NavigationService.NavigateAsync(PopupName.SuccessfullPopup, parameters);
            }

            IsEmpty   = Items.Count == 0;
            IsLoading = false;
        }