Example #1
0
        /* ==================================================================================================
         * example for action in service usage (farmiliar to sysfx)
         * this way vs handling in viewmodel are same
         * ================================================================================================*/
        public async Task Get(Action <List <PhotoDto> > onSuccessAction, Action onFailedAction, CancellationToken extToken)
        {
            //await Task.Delay(2000);
            var pair = await RestServiceHelper.CallWithRetry(() => _photoApi.Get(extToken), RetryMode.Confirm);

            switch (pair.ExtendedResult.Result)
            {
            case ApiResult.Failed:
                /* ==================================================================================================
                 * failed api call
                 * ================================================================================================*/
                onFailedAction?.Invoke();
                break;

            case ApiResult.Ok:
                /* ==================================================================================================
                 * success api call
                 * ================================================================================================*/
                onSuccessAction?.Invoke(pair.MainResult);
                break;

            case ApiResult.Canceled:
                /* ==================================================================================================
                 * Do nothing
                 * ================================================================================================*/
                break;

            default:
                break;
            }
        }
Example #2
0
        public async Task <PostDto> CreatePost(PostDto dto)
        {
            /* ==================================================================================================
             * map dto to request for api call
             * ================================================================================================*/
            var request = dto.MapTo <CreatePostRequest>();

            /* ==================================================================================================
             * action call
             * ================================================================================================*/
            var pair = await RestServiceHelper.CallWithRetry(() => _postsApi.Create(request));

            /* ==================================================================================================
             * exp dont care about extended result
             * ================================================================================================*/
            return(pair.MainResult);
        }
Example #3
0
        public async Task <PhotoDto> GetWithSilentRetryUntilSuccess(int id)
        {
            var pair = await RestServiceHelper.CallWithRetry(() => _photoApi.Get(id), RetryMode.SilentUntilSuccess);

            return(pair.MainResult);
        }
Example #4
0
        public async Task <PhotoDto> Get(int id)
        {
            var pair = await RestServiceHelper.CallWithRetry(() => _photoApi.Get(id), RetryMode.Confirm);

            return(pair.MainResult);
        }