UsersViewModel convertGoogle(UserGoogleViewModel model) { UsersViewModel usermodel = new UsersViewModel(); usermodel.provider = ProviderEnum.Google; usermodel.userEmailAdress = model.email; usermodel.userName = model.given_name; usermodel.userSurname = model.family_name; return(usermodel); }
public UsersViewModel getDataFromProvider(ProviderEnum provider, string token, string userid) { UsersViewModel model = new UsersViewModel(); uri_facebook = uri_facebook + userid + "?fields=email,first_name,last_name&access_token=" + token; uri_google = uri_google + token; HttpClient http = new HttpClient(); var data = http.GetAsync(provider == ProviderEnum.Facebook ? uri_facebook : uri_google).Result.Content.ReadAsStringAsync().Result; if (provider == ProviderEnum.Facebook) { UserFacebookViewModel facebookModel = JsonConvert.DeserializeObject <UserFacebookViewModel>(data); model = convertFacebook(facebookModel); } else { UserGoogleViewModel googleModel = JsonConvert.DeserializeObject <UserGoogleViewModel>(data); model = convertGoogle(googleModel); } return(model); }