public IActionResult Get(string insureeNumber) { DataMessage response; try { if (insureeNumber != null || insureeNumber.Length != 0) { var data = _imisModules.GetInsureeModule().GetFamilyLogic().Get(insureeNumber); if (data.Count > 0) { response = new GetFamilyResponse(0, false, data, 0).Message; } else { response = new GetFamilyResponse(2, false, 0).Message; } } else { response = new GetFamilyResponse(1, true, 0).Message; } } catch (Exception e) { response = new GetFamilyResponse(e).Message; } return(Json(response)); }
public Task <FamilyDTO> GetFamilyAsync(CancellationTokenSource cancellationTokenSource) => Task <FamilyDTO> .Run(async() => { if (!CrossConnectivity.Current.IsConnected) { throw new InvalidOperationException(AppConsts.ERROR_INTERNET_CONNECTION); } FamilyDTO familyDTO = null; GetFamilyRequest getFamilyRequest = new GetFamilyRequest() { AccessToken = GlobalSettings.Instance.UserProfile.AccesToken, Url = GlobalSettings.Instance.Endpoints.FamilyEndpoints.GetFamilyEndpoint }; try { GetFamilyResponse getFamilyResponse = await _requestProvider.GetAsync <GetFamilyRequest, GetFamilyResponse>(getFamilyRequest); if (getFamilyResponse != null) { familyDTO = new FamilyDTO() { Id = getFamilyResponse.Id, Members = getFamilyResponse.Members, ParentId = getFamilyResponse.ParentId }; } } catch (HttpRequestExceptionEx exc) { GetFamilyResponse erroredGetFamilyResponse = JsonConvert.DeserializeObject <GetFamilyResponse>(exc.Message); string output = string.Format("{0}", erroredGetFamilyResponse.Errors?.FirstOrDefault()); output = (string.IsNullOrWhiteSpace(output) || string.IsNullOrEmpty(output)) ? GET_FAMILY_COMMON_ERROR : output; throw new InvalidOperationException(output.Trim()); } catch (ServiceAuthenticationException exc) { _identityUtilService.RefreshToken(); throw exc; } catch (Exception exc) { Crashes.TrackError(exc); throw exc; } return(familyDTO); });