Beispiel #1
0
        public static async Task <TResult> HandleApiResult <TResult>(Func <Task <ApiResult <TResult> > > request)
        {
            var result = await request();

            if (result.Success)
            {
                return(result.Result);
            }

            if (result.Error.Equals(Constants.Errors.LoginRequired))
            {
                await RequestLoginHelper.RequestLogin(async() =>
                {
                    result = await request();
                    if (result.Success)
                    {
                        return;
                    }
                    _toastSerivce.ShowByValue(result.Error);
                });

                if (result.Success)
                {
                    return(result.Result);
                }
            }
            else
            {
                _toastSerivce.ShowByValue(result.Error);
            }

            return(default(TResult));
        }
Beispiel #2
0
        public static async Task HandleApiResult(Func <Task <ApiResult> > request, Action onSuccess)
        {
            var result = await request();

            if (result.Success)
            {
                onSuccess();
                return;
            }

            if (result.Error.Equals(Constants.Errors.LoginRequired))
            {
                await RequestLoginHelper.RequestLogin(async() =>
                {
                    result = await request();
                    if (result.Success)
                    {
                        onSuccess();
                        return;
                    }
                    _toastSerivce.ShowByValue(result.Error);
                });
            }
            else
            {
                _toastSerivce.ShowByValue(result.Error);
            }
        }