public bool Update(ClientUpdateCommand cmd) { var clientDb = _clientRepository.GetById(cmd.Id) ?? throw new NotFoundException(); Mapper.Map(cmd, clientDb); return(_clientRepository.Update(clientDb)); }
public void TranslateExternalUpdateCommandToAkkaMessage(HTTPSourcedCommand cmdExternal) { ClientState cs; if (ExtractStateObject(cmdExternal, out cs)) { ClientUpdateCommand updateCmd = new ClientUpdateCommand(cs, cmdExternal.User, cmdExternal.ConnectionId); SendTo.Tell(updateCmd, ReplyTo); } }
public void SetUp() { AutoMapperInitializer.Reset(); AutoMapperInitializer.Initialize(); _client = ObjectMother.GetClientValid(); _clientRegister = Mapper.Map <ClientRegisterCommand>(_client); _clientUpdate = Mapper.Map <ClientUpdateCommand>(_client); _clientRemove = Mapper.Map <ClientRemoveCommand>(_client); _mockRepository = new Mock <IClientRepository>(); _service = new ClientService(_mockRepository.Object); }
public IHttpActionResult Put(ClientUpdateCommand cmd) { var validator = cmd.Validate(); if (!validator.IsValid) { return(HandleValidationFailure(validator.Errors)); } return(HandleCallback(() => _clientService.Update(cmd))); }
public async Task UpdateClient(ClientUpdateCommand command) { var content = new StringContent( JsonSerializer.Serialize(command), Encoding.UTF8, "application/json" ); var request = await _httpClient.PutAsync($"{_apiUrls.CustomerUrl}v1/clients", content); request.EnsureSuccessStatusCode(); }
private void PostUpdateHandler(ClientUpdateCommand c) { // Update updatable fields _ActorState.Update(c.ClientStateData); AutoSaveSnashot(false); _logger.Debug($"User:{c.User} updated client id:{_ActorState.Id}."); // Update whoever requested it with the new state ClientUpdatedEvent message = new ClientUpdatedEvent(_ActorState.Clone(), c.User, c.ConnectionId); Sender.Tell(message, Self); // Notify interested actors on the update NotifyCommandEventSubscribers(message); }
private bool UpdateClientCommand(ClientUpdateCommand c) { if (_ActorState.isActive == false) { ClientFailedUpdateEvent msg = new ClientFailedUpdateEvent(string.Format("Client is deleted(inactive)."), c.ClientStateData, c.User, c.ConnectionId); Sender.Tell(msg); return(true); } // Enforce required fields if (c.ClientStateData.Name == null || c.ClientStateData.Name == "") { ClientFailedUpdateEvent msg = new ClientFailedUpdateEvent(string.Format("UserName field cannot be blank(or null)."), c.ClientStateData, c.User, c.ConnectionId); Sender.Tell(msg); return(true); } Persist <ClientUpdateCommand>(c, PostUpdateHandler); return(true); }
public async Task <ActionResult> Update(ClientUpdateCommand command) { await _customerProxy.UpdateClient(command); return(Ok()); }
public async Task <ActionResult> Update(ClientUpdateCommand command) { await _mediator.Publish(command); return(Ok()); }
private bool UpdateClientRecoveryCommand(ClientUpdateCommand c) { // Update updatable fields _ActorState.Update(c.ClientStateData); return(true); }