public async Task AddClientAsync_ShouldCreateAndReturnNewClient() { var addClientRequest = new AddClientRequest(SaasUserId, "*****@*****.**", "7F97D474-3CBA-45E8-A90C-3955A3CBF59D", "user agent1", "*****@*****.**"); var newClient = await _clientService.AddClientAsync(addClientRequest); Assert.NotNull(newClient); Assert.Equal(addClientRequest.ConnectionId, newClient.ConnectionClientId); Assert.Equal(addClientRequest.UserName, newClient.UserName); }
public async Task <Client> AddClientUserAsync(ClientViewModel clientModel) { var client = BindClientModelToClient(clientModel); var clientAdded = await _clientService.AddClientAsync(client); return(clientAdded); }
public async Task <IActionResult> Client(ClientDto client) { client = _clientService.BuildClientViewModel(client); if (!ModelState.IsValid) { return(View(client)); } //Add new client if (client.Id == 0) { var clientId = await _clientService.AddClientAsync(client); SuccessNotification(string.Format(_localizer["SuccessAddClient"], client.ClientId), _localizer["SuccessTitle"]); return(RedirectToAction(nameof(Client), new { Id = clientId })); } //Update client await _clientService.UpdateClientAsync(client); SuccessNotification(string.Format(_localizer["SuccessUpdateClient"], client.ClientId), _localizer["SuccessTitle"]); return(RedirectToAction(nameof(Client), new { client.Id })); }
public async Task ClientService_ClientExists_ReturnsTrue_WhenClientDoesExist() { //Arrange const int clientId = 1; const string clientName = "Test Client"; const string clientEventCallbackUrl = "http://someurl.com"; var addClientResult = await _clientService.AddClientAsync(clientId, clientName, clientEventCallbackUrl).ConfigureAwait(false); //Act var clientExists = await _clientService.ClientExistsAsync(clientId).ConfigureAwait(false); //Assert Assert.IsTrue(addClientResult.OperationSuccessful); Assert.IsTrue(clientExists); }
public async Task <IActionResult> Post([FromBody] ClientApiDto client) { var clientDto = client.ToClientApiModel <ClientDto>(); await _clientService.AddClientAsync(clientDto); return(Ok()); }
public async Task <IActionResult> Post([FromBody] ClientDto clientToAdd) { if (!ModelState.IsValid) { return(BadRequest("Invalid client model. Please provide Identity Id.")); } if ((await _userManager.FindByIdAsync(clientToAdd.IdentityId)) == null) { return(BadRequest($"No user with prvided user Id {clientToAdd.IdentityId} has been found.")); } if (clientToAdd.Offers != null) { if (clientToAdd.Offers?.Count != 0) { foreach (var offer in clientToAdd.Offers) { if (!await _carService.CarExistsAsync(offer.Id)) { return(BadRequest($"No car with provided Id {offer.Id} has been found.")); } } } } var clientInDb = await _clientService.AddClientAsync(clientToAdd); if (clientInDb == null) { return(Conflict(new { Error = "Request unsuccessfull." })); } return(Ok(clientInDb)); }
public async Task <IActionResult> AddClientAsync(string connectionId) { var addClientRequest = new AddClientRequest(GetCurrentSaasUserId(), GetCurrentUserName(), connectionId, null, GetCurrentUserEmail()); var result = await _clientService.AddClientAsync(addClientRequest); return(Ok(result)); }
public async Task <ClientResponse> AddClientAsync() { return(await SafeExecuteAsync(new TaskReference <ClientResponse>(async() => { var addClientRequest = new AddClientRequest(Context.GetSaasUserId(), Context.GetUserName(), Context.ConnectionId, null, Context.GetEmail()); return await _clientService.AddClientAsync(addClientRequest); }))); }
public async Task <IActionResult> AddClientAsync([FromBody] AddClientPost addClientRequest) { var client = Mapper.Map <Client>(addClientRequest); await clientService.AddClientAsync(client); return(Ok(client)); }
public async Task <IActionResult> Add(AddClientDto addClientDto) { if (!ModelState.IsValid) { return(View()); } await _clientService.AddClientAsync(addClientDto); return(RedirectToAction("list", "client")); }
public async Task <IActionResult> New([FromBody] Client client) { var success = await _service.AddClientAsync(client); if (success) { return(Success()); } return(Error()); }
public async Task <string> SaveClient([FromBody] ClientRegistryDto client) { ClientsDto clients = await _clientService.GetClientsAsync(client.ClientName, 1, 1); if (clients.Clients.Count > 0) { throw new UserFriendlyErrorPageException($"客户端[{client.ClientId}]已经存在"); } else { string clientSecret = Guid.NewGuid().ToString("N").ToLower(); ClientDto clientDto = ToClientDto(client); int clientId = await _clientService.AddClientAsync(clientDto); await _clientService.AddClientSecretAsync(new ClientSecretsDto() { Value = clientSecret, Description = clientSecret, ClientId = clientId }); client.ClientSecret = clientSecret; foreach (var item in client.Properties) { await _clientService.AddClientPropertyAsync(new ClientPropertiesDto() { Key = item.Key, Value = item.Value, ClientId = clientId, ClientName = client.ClientName }); } return(clientSecret); } }
public async Task <IActionResult> Client(ClientDto client) { client = _clientService.BuildClientViewModel(client); var isAdmin = await _authorization.IsAdmin(User); if (!ModelState.IsValid) { return(View(client)); } //Add new client if (client.Id == 0) { var clientId = await _clientService.AddClientAsync(client); await _clientManagerService.AddClientManagerAsync(clientId, User.GetSubjectId()); SuccessNotification(string.Format(_localizer["SuccessAddClient"], client.ClientId), _localizer["SuccessTitle"]); return(RedirectToAction(nameof(Client), new { Id = clientId })); } //Update client if (!isAdmin && !(await _clientManagerService.IsClientManagerAsync(client.Id, User.GetSubjectId()))) { UnauthorizedNotification(); } else { await _clientService.UpdateClientAsync(client); SuccessNotification(string.Format(_localizer["SuccessUpdateClient"], client.ClientId), _localizer["SuccessTitle"]); } return(RedirectToAction(nameof(Client), new { client.Id })); }
public async Task <IActionResult> Client(ClientDto client) { client = _clientService.BuildClientViewModel(client); if (!ModelState.IsValid) { return(Success(client)); } //Add new client if (client.Id == 0) { var clientId = await _clientService.AddClientAsync(client); return(Success(new { Id = clientId })); } //Update client await _clientService.UpdateClientAsync(client); return(Success(new { client.Id })); }
public async Task <ActionResult <ClientDTO> > CreateClientAsync([FromBody] ClientDTO dto) { var result = await clientService.AddClientAsync(dto); return(Ok(result)); }
public void Add_Client_Success() { clientService.AddClientAsync(client); Assert.IsType <Client>(client); }
public async Task <bool> AddClient([FromBody] ClientModel clientModel) { return(await _clientService.AddClientAsync(clientModel)); }