public async Task<UserProfile> GetUserProfile() { UserIdentityEntity userIdentityEntity = userIdentityRepository.GetAll().LastOrDefault(); UserProfileEntity userProfileEntity = null; userProfile = null; if (userIdentityEntity != null && !string.IsNullOrEmpty(userIdentityEntity.Email)) { userProfile = await userService.GetUserProfileByAuthLocalId(userIdentityEntity.LocalId); //Below code: tries to get latest data from server (and update cached data), otherwise get from cached data if (userProfile == null) { Navigator.Instance.OkAlert("Alert", "Currently in offline mode due to issue on server. Your profile is temporarily not synced.", "OK"); userProfileEntity = userProfileRepository.GetUserProfile(userIdentityEntity.Email); userProfile = ConvertProfileEntityToUserProfile(userProfileEntity); } else { var row = userProfileRepository.CreateOrUpdate(GetUserProfileEntity()); if (row < 0) { Navigator.Instance.OkAlert("Alert", "There is an issue trying to update your profile onto your device from server.", "OK"); } } } return userProfile; }
public IHttpActionResult Get(ODataQueryOptions <UserIdentity> queryOptions) { logger.Trace("Call UserIdentitysController Get All"); try { queryOptions.Validate(_validationSettings); } catch (ODataException ex) { return(BadRequest(ex.Message)); } var data = UserIdentityRepository.GetAll(); var query = (IQueryable <UserIdentity>)queryOptions .ApplyTo(data.AsQueryable()); return(Ok(query)); }