protected static void SetObjectVersionIfNotExist(BaseCommandWithInitiator command, ObjectEntity originalEntity) { if (originalEntity.Version == null) { originalEntity.Version = new VersionInfoEntity(1, new UserInfoEntity(command.UserId, command.UserName, command.Email)); } }
protected async Task IncObjectVersion(BaseCommandWithInitiator command, ObjectEntity originalEntity, ObjectEntity newEntity, CancellationToken cancellationToken) { await _context.ObjectVersions.InsertOneAsync(originalEntity, cancellationToken : cancellationToken); newEntity.Version = new VersionInfoEntity(originalEntity.Version.VersionId + 1, new UserInfoEntity(command.UserId, command.UserName, command.Email)); }