Integration
The General Arrangements service offers some messages that can be published, as
well as some events that another services can consume, to keep their data up to
date.
First of all, we need a reference to the
GeneralArrangements.Application.Contracts
project, as it's shown below:
XML |
---|
| <ProjectReference Include="$(ServicesPath)General Arrangements\ITsynch.Suite.General Arrangements.Application.Contracts\ITsynch.Suite.General Arrangements.Application.Contracts.csproj" />
|
General Arrangement
General Arrangement establishes some events for other services to interact with.
General Arrangement Updated:
C# |
---|
| using ITsynch.Suite.GeneralArrangements.Application;
using MassTransit;
using System.Threading.Tasks;
namespace ITsynch.Suite.Example.Application
{
public class GeneralArrangementUpdatedConsumer : IConsumer<GeneralArrangementUpdated>
{
public GeneralArrangementUpdatedConsumer()
{
}
public async Task Consume(ConsumeContext<GeneralArrangementUpdated> context)
{
// Write down your logic here.
}
}
}
|
Level
Level establishes some messages and events for other services to interact with.
Level Messages
From your module, you are able to request six different Level actions:
Create a new Level:
C# |
---|
| await this.PublishEndpoint.Publish<CreateLevel>(new
{
CorrelationId = NewId.NextGuid(),
DisplayName = "Deck 00",
Number = 0,
LocationId = deckLocationId,
GeneralArrangementId = fakeShipGeneralArrangementId,
Zones = new List {kitchen1ZoneId, fireZone1ZoneId, fireZone2ZoneId}
});
|
Update a Level:
C# |
---|
| await this.PublishEndpoint.Publish<UpdateLevel>(new
{
CorrelationId = levelId,
DisplayName = "Deck 01",
Number = 1,
LocationId = deck1LocationId,
});
|
Add a Zone at a Level:
C# |
---|
| await this.PublishEndpoint.Publish<AddZone>(new
{
CorrelationId = levelId,
ZoneId = zoneId,
});
|
Remove a Zone from a Level:
C# |
---|
| await this.PublishEndpoint.Publish<RemoveZone>(new
{
CorrelationId = levelId,
ZoneId = zoneId,
});
|
Level Events
On the other hand, you can consume the different Level's events and perform the
actions you need to do in your project.
Level Updated:
C# |
---|
| using ITsynch.Suite.GeneralArrangements.Application;
using MassTransit;
using System.Threading.Tasks;
namespace ITsynch.Suite.Example.Application
{
public class LevelUpdatedConsumer : IConsumer<LevelUpdated>
{
public LevelUpdatedConsumer()
{
}
public async Task Consume(ConsumeContext<LevelUpdated> context)
{
// Write down your logic here.
}
}
}
|
Zone
Zone establishes some events for other services to interact with.
Zone Updated:
C# |
---|
| using ITsynch.Suite.GeneralArrangements.Application;
using MassTransit;
using System.Threading.Tasks;
namespace ITsynch.Suite.Example.Application
{
public class ZoneUpdatedConsumer : IConsumer<ZoneUpdated>
{
public ZoneUpdatedConsumer()
{
}
public async Task Consume(ConsumeContext<ZoneUpdated> context)
{
// Write down your logic here.
}
}
}
|
Location Link
Location Link establishes some events for other services to interact with.
Location Link Updated:
C# |
---|
| using ITsynch.Suite.GeneralArrangements.Application;
using MassTransit;
using System.Threading.Tasks;
namespace ITsynch.Suite.Example.Application
{
public class LocationLinkUpdatedConsumer : IConsumer<LocationLinkUpdated>
{
public LocationLinkUpdatedConsumer()
{
}
public async Task Consume(ConsumeContext<LocationLinkUpdated> context)
{
// Write down your logic here.
}
}
}
|
Section
Section establishes some events for other services to interact with.
Section Updated:
C# |
---|
| using ITsynch.Suite.GeneralArrangements.Application;
using MassTransit;
using System.Threading.Tasks;
namespace ITsynch.Suite.Example.Application
{
public class SectionUpdatedConsumer : IConsumer<SectionUpdated>
{
public SectionUpdatedConsumer()
{
}
public async Task Consume(ConsumeContext<SectionUpdated> context)
{
// Write down your logic here.
}
}
}
|
See Also