public async Task<IEnumerable<SearchResult>> Search(Profile profileToSearch) // 100% { var parameters = new Dictionary<string, string>(); if (profileToSearch.surName != null) { parameters.Add("name", profileToSearch.givenName + " " + profileToSearch.surName); } else if (profileToSearch.surName == null) { parameters.Add("name", profileToSearch.givenName); } if (profileToSearch.genderId != null) { parameters.Add("genderId", profileToSearch.genderId); } if (profileToSearch.birthCountryId != null) { parameters.Add("countryOfBirthId", profileToSearch.birthCountryId); } if (profileToSearch.lastSighting != null) { parameters.Add("lastSighting", profileToSearch.lastSighting); } if (profileToSearch.otherInformation != null) { parameters.Add("otherInformation", profileToSearch.otherInformation); } var y = await Api("search/", parameters); //Raw data var x = JsonConvert.DeserializeObject<PagedResponse<SearchResult>>(y); //Processed return x.results; }
public async Task<Profile> Register(Device device, Profile profile) //100% { var postParameters = new Dictionary<string, string> { {"username", profile.username}, {"password", profile.password}, {"primaryEmail", profile.primaryEmail}, {"referralId", profile.referralId}, {"genderId", profile.genderId}, {"givenName", profile.givenName}, {"surName", profile.surName}, {"birthCountryId", profile.birthCountryId}, {"owningMonitorProfileId", profile.owningMonitorProfileId}, {"owningPartnerProfileId", profile.owningPartnerProfileId}, {"dialCode", profile.dialCode}, {"cellPhone", device.Number}, {"clientCountryId", profile.clientCountryId}, {"lastSighting", profile.lastSighting}, {"nickName", profile.nickName}, {"otherInformation", profile.otherInformation}, {"otherName", profile.otherName}, {"tribe", profile.tribe}, {"alternateEmail", profile.alternateEmail}, {"homeTown", profile.homeTown}, {"preferredLanguageId", profile.preferredLanguageId}, {"userProfileStateId", profile.userProfileStateId}, {"actingUserProfileId", profile.actingUserProfileId}, {"assistingUserProfileId", profile.assistingUserProfileId}, {"sessionId", profile.sessionId}, }; var y = await Api("profile/", postParameters: postParameters); var x = JsonConvert.DeserializeAnonymousType(y, new {profile = new {id = 0}}); return await GetProfile(x.profile.id.ToString()); //EG "\n{\"profile\":{\"id\":324865}}" }
public async Task<ActionResult> Index() { //Test Data var testProfile = new Profile { username = "", givenName = "kaelanc", surName = "fouwelsc", password = "******", otherInformation = "I like trains", lastSighting = "Test" }; var testDevice = new Device { Number = "+447842073150" }; //Test Data var testUsername = await RefugeesUnitedService.GenerateUsername(testProfile.givenName, testProfile.surName); testProfile.username = testUsername; //Get API to generate a Username var testUserExists = await RefugeesUnitedService.UserExists(testProfile.username); //Check if user exists //var testRegister = await RefugeesUnitedService.Register(testDevice, testProfile); // todo <-- Problematic //Attempt to register said user var testLogin = await RefugeesUnitedService.Login(testDevice, "kaelanc.fouwelsc", "1234"); //Atempt to login said user var testSearch = await RefugeesUnitedService.Search(testProfile); //Search for said user var testLogout = await RefugeesUnitedService.Logout("kaelanc.fouwelsc"); //Attempt to logout said user //Break here return Content(""); }
public async Task<Profile> Register(Profile user, Device device) { return await RefugeesUnitedService.Register(device, user); }