예제 #1
0
        public async void LoadAsync()
        {
            var peopleResult = await _faultlessExecutionService.TryExecuteAsync(() => _database.GetAllThePeopleInTheWorldAsync());

            if (!peopleResult.WasSuccessful)
            {
                return;
            }

            this.LoadPersonList(peopleResult.ReturnValue);

            var cityResult = await _faultlessExecutionService.TryExecuteAsync(() => _webApi.GetSomeCitiesAsync());

            if (!cityResult.WasSuccessful)
            {
                return;
            }

            this.LoadCityList(cityResult.ReturnValue);

            var answerResult = await _faultlessExecutionService.TryExecuteAsync(() => _cloud.GetAllTheAnswersAsync());

            if (!answerResult.WasSuccessful)
            {
                return;
            }

            this.LoadAnswerList(answerResult.ReturnValue);
        }
        public async Task <IActionResult> TryExecuteAsync <T>(Func <Task <T> > code)
        {
            var result = await _faultlessExecutionService.TryExecuteAsync(code);

            if (result.WasSuccessful)
            {
                return(new OkObjectResult(result.ReturnValue));
            }
            else
            {
                _logger.LogError(result.Exception, "Exception caught; BadRequest with FailModel will be sent to client");
                return(new BadRequestObjectResult(this.BuildBadRequestObject(result)));
            }
        }