public bool UpdateProfile(CertificationProfileInitializeModel profile) { if (!IsInitialized || IsDeleted) { return(false); } this.LastName = profile.LastName; this.FirstName = profile.FirstName; this.Email = profile.Email; return(true); }
public async Task GenerateProfilesAsync(int numberOfProfiles, CancellationToken token) { for (int i = 0; i < numberOfProfiles; i++) { var profile = new CertificationProfileInitializeModel(); profile.Id = Guid.NewGuid(); profile.FirstName = GenerateFirstName(); profile.LastName = GenerateLastName(); profile.Email = GenerateEmail(profile.LastName, profile.FirstName); if (await this._profilesProvider.AddCertificationProfileAsync(profile, token)) { var certifications = GenerateCertifications(); foreach (var certification in certifications) { await this._profilesProvider.AddCertificationAsync(profile.Id, certification, token); } } } }
public async Task <bool> AddCertificationProfileAsync( CertificationProfileInitializeModel profile, CancellationToken token) { if (profile == null) { throw new ArgumentNullException(nameof(profile)); } var uri = this.CreateAPIUri(""); profile.Id = Guid.NewGuid(); var profileJson = JsonSerializer.Serialize(profile, new JsonSerializerOptions { PropertyNameCaseInsensitive = true, }); var postContent = new StringContent(profileJson, Encoding.UTF8, "application/json"); var response = await this._httpClient.PostAsync(uri, postContent, token); return(response.IsSuccessStatusCode); }