Ejemplo n.º 1
0
        public bool Update(ClientUpdateCommand cmd)
        {
            var clientDb = _clientRepository.GetById(cmd.Id) ?? throw new NotFoundException();

            Mapper.Map(cmd, clientDb);

            return(_clientRepository.Update(clientDb));
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        public IHttpActionResult Put(ClientUpdateCommand cmd)
        {
            var validator = cmd.Validate();

            if (!validator.IsValid)
            {
                return(HandleValidationFailure(validator.Errors));
            }

            return(HandleCallback(() => _clientService.Update(cmd)));
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        public async Task <ActionResult> Update(ClientUpdateCommand command)
        {
            await _customerProxy.UpdateClient(command);

            return(Ok());
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> Update(ClientUpdateCommand command)
        {
            await _mediator.Publish(command);

            return(Ok());
        }
Ejemplo n.º 10
0
 private bool UpdateClientRecoveryCommand(ClientUpdateCommand c)
 {
     // Update updatable fields
     _ActorState.Update(c.ClientStateData);
     return(true);
 }