public async Task <ICommandResult> Handle(CreateEventCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Invalid operation!", command.Notifications)); } var sensorMock = _sensorService.GetSensorFromString(command.Tag); var sensor = await _sensorRepository.GetSensorByNameAndRegionAndCountry(sensorMock); var status = string.IsNullOrEmpty(command.Value.ToString()) ? EventStatus.Error : EventStatus.Processed; var @event = new Event ( sensor.Id, command.Value, command.Timestamp, status ); await _eventRepository.AddAsync(@event); await _eventWs.sendEventsToAll(); return(new GenericCommandResult(true, "Event created!", new { @event.Id })); }