public void Handle(UpdateDeviceCommand command) { var device = new Device() { Appliance = command.Appliance, ID = command.ID, Name = command.Name, NodeAddress = command.NodeAddress }; repository.Update(device); eventServer.SendToAll(EventTypes.DeviceUpdated, device); }
public async Task <ActionResult> Update(int id, UpdateDeviceCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public async Task UpdateDevice_Call() { //-------------- Arrange ------------- CommonArrangements(); var request = new UpdateDeviceRequest(); var command = new UpdateDeviceCommand(); A.CallTo(() => mapper.Map <UpdateDeviceRequest, UpdateDeviceCommand>(request)).Returns(command); //-------------- Act ------------- var resp = deviceService.UpdateDeviceAsync(request); //-------------- Assert ------------- A.CallTo(() => bus.SendAsync(command)).MustHaveHappened(Repeated.Exactly.Once); }
public IActionResult Put([FromBody] UpdateDeviceCommand command) { commandBus.Execute(command); return(Ok()); }