public SerializedEvent Serialize(BaseLockMessage message) { return(new SerializedEvent { Id = message.EventId, AggregateId = message.LockId, CreatedDate = message.EventCreatedDate, EventType = message.GetType().Name, UserId = message.UserId, Data = JsonConvert.SerializeObject(message) }); }
public async Task CreateAsync_NotNulModel_Created() { // Arrange BaseLockMessage entity = _fixure.Create <LockCreatedMessage>(); // Act var created = await _repository.CreateAsync(entity); // Assert entity.LockId.Should().Be(created.AggregateId); entity.EventCreatedDate.Should().Be(created.CreatedDate); entity.EventId.Should().Be(created.Id); entity.UserId.Should().Be(created.UserId); }
public async Task <SerializedEvent> CreateAsync(BaseLockMessage @event) { var serializedEvent = _serializer.Serialize(@event); using (var db = Connection) { await db.ExecuteAsync( "INSERT INTO LocksActivity " + $"({nameof(SerializedEvent.Id)}, {nameof(SerializedEvent.CreatedDate)}, {nameof(SerializedEvent.AggregateId)}, " + $"{nameof(SerializedEvent.UserId)}, {nameof(SerializedEvent.EventType)}, {nameof(SerializedEvent.Data)}) " + "VALUES " + $"(@{nameof(SerializedEvent.Id)}, @{nameof(SerializedEvent.CreatedDate)}, @{nameof(SerializedEvent.AggregateId)}, " + $"@{nameof(SerializedEvent.UserId)}, @{nameof(SerializedEvent.EventType)}, @{nameof(SerializedEvent.Data)}) ", serializedEvent ).ConfigureAwait(false); } return(serializedEvent); }