public void InsertProviderAccount(SocialProviderAddRequest model, Provider type) { string t = null; //Select the correct stored procedure based on the passed in provider type switch (type) { case Provider.LinkedIn: t = "LinkedIn"; break; case Provider.Facebook: t = "Facebook"; break; case Provider.Google: t = "Google"; break; default: return; } //Inserts the account id and the user id into the correct table DataProvider.ExecuteNonQuery( "Accounts_" + t + "_Insert", inputParamMapper : delegate(SqlParameterCollection paramCol) { paramCol.AddWithValue("@Id", model.Id); paramCol.AddWithValue("@ProviderId", model.ProviderId); } ); }
//Function - Takes a user model, and provider and logs the user in public bool LogIn(SocialProviderUser model, Provider type) { //Gets the provider Id from the table string tableProviderId = GetProviderId(model.Id, type); //If the provider Id does not match the one in the table return an error if (tableProviderId != null && tableProviderId != model.ProviderId) { log.Error("The provided Id: " + model.ProviderId + " does not match the one in the table: " + tableProviderId); return(false); } //If the provider Id was not in the table - add it to the table if (tableProviderId == null) { SocialProviderAddRequest spModel = new SocialProviderAddRequest(); spModel.Id = model.Id; spModel.ProviderId = model.ProviderId; //Adds the provider Id into the db with the account Id and the provider Id InsertProviderAccount(spModel, type); } //Calls the login function with the passed in model which creates the cookie for logging in _userService.LogInSocial(model); return(true); }