private async Task <bool> HandleShipDocked(string message) { var receivedShip = Newtonsoft.Json.JsonConvert.DeserializeObject <ShipDockedMessageEvent>(message); await _shipRepository.CreateShip(receivedShip.ShipId, receivedShip.CustomerId, receivedShip.ShipName); return(true); }
public async Task Consume(ConsumeContext <IOrder> context) { var order = context.Message; var result = await _shipRepository.CreateShip(order); if (result) { IOrderEventEntity orderEventEntity = new OrderEventEntity { OrderID = order.ID, EventType = "CreateOrder", ShipStatus = 2 }; await Startup.BusControl.Publish(orderEventEntity); } }
private async Task <bool> HandleShipDocked(string message) { var receivedShip = JsonSerializer.Deserialize <ShipDockedEventModel>(message); Ship ship = new Ship() { Containers = receivedShip.Containers, CustomerId = receivedShip.CustomerId, Id = receivedShip.ShipId }; Ship createdShip = await _shipRepository.CreateShip(ship); foreach (var container in createdShip.Containers) { await _containerRepository.CreateContainerAsync(container); } return(true); }
public Task <Ship> CreateShipAsync(Ship ship) { return(_shipRepository.CreateShip(ship)); }