public void CreateRequestIsMade_InvalidCustomerId_ValidationShouldFail() { var validatorService = new PasswordValidator(CreateDefaultValidationRules()); var request = new CredentialsCreateRequest { CustomerId = "", Login = "******", Password = "******" }; var validator = new CreateRequestCredentialsValidator(validatorService); var result = validator.Validate(request); Assert.False(result.IsValid); }
public void CreateRequestIsMade_CorrectCredentials_ValidationPassSuccessfully() { var validatorService = new PasswordValidator(CreateDefaultValidationRules()); var request = new CredentialsCreateRequest { CustomerId = "mockId", Login = "******", Password = "******" }; var validator = new CreateRequestCredentialsValidator(validatorService); var result = validator.Validate(request); Assert.True(result.IsValid); }
public ActionResult <string> Post([FromBody] PersonCreateRequest personCreateRequest) { var sw = Stopwatch.StartNew(); var person = personServices.CreatePerson(personCreateRequest); if (person == null) { return("Email ID already exist. Please try different ID"); } var credentialCreateRequest = new CredentialsCreateRequest(person); credentialService.CreateCredentials(credentialCreateRequest); sw.Stop(); LoginDuration .WithLabels("Create_Person") .Observe(sw.Elapsed.TotalSeconds); return("User Created ID: " + person.PersonId.ToString()); }
public async Task <CredentialsCreateResponse> CreateAsync([FromBody] CredentialsCreateRequest request) { var credentials = await _customerCredentialsService.GetAsync(request.Login); if (credentials != null) { _log.Info("Credentials already exists", request.Login.SanitizeEmail()); return(new CredentialsCreateResponse { Error = CredentialsError.LoginAlreadyExists }); } await _customerCredentialsService.CreateAsync( request.CustomerId, request.Login, request.Password); return(new CredentialsCreateResponse()); }
public void CreateCredentials(CredentialsCreateRequest credentialsCreateRequest) { var cred = new Credentials(credentialsCreateRequest); _credentials.InsertOneAsync(cred).Wait(); }
public Credentials(CredentialsCreateRequest credentialsCreateRequest) { PersonId = credentialsCreateRequest.PersonId; EmailId = credentialsCreateRequest.EmailId; Password = credentialsCreateRequest.Password; }