public User createUser(User toSave) { if (_repo.getUserFromDatabase(toSave.citizenServiceNumber) != null) { return(null); } toSave.password = generatePassword(toSave.password); RegistrationModel model = new RegistrationModel { LastName = toSave.lastName, CitizenServiceNumber = toSave.citizenServiceNumber, FirstName = toSave.firstName }; HttpResponseMessage response = RestHelper.AasHttpClient() .PostAsync($"owners", RestHelper.ConvertToSendableHttpObject(model)).Result; response.EnsureSuccessStatusCode(); string msg = response.Content.ReadAsStringAsync().Result; RestUserModel mod = JsonConvert.DeserializeObject <RestUserModel>(msg); toSave.address = mod.Address; toSave.birthDay = DateTime.ParseExact(mod.Birthday, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture); toSave.cars = _carService.GetCarsOfUserFromAAS(toSave.citizenServiceNumber) as List <Car>; toSave.Language = "NLD"; toSave.lastSyncTime = DateTime.Now; toSave.invoices = new List <Invoice>(); return(_repo.Add(toSave)); }