public async Task <ExecutionResult <List <Shipment> > > GetShipmentsAsync() { var query = new GetShipmentsQuery(); var result = await _mediator.Send(query); return(result); }
public async Task <List <ShipmentResponse> > Handle(GetShipmentsQuery request, CancellationToken cancellationToken) { var shipments = await _shipmentService.GetShipmentsAsync(); var shipmentResponseList = new List <ShipmentResponse>(); foreach (var shipment in shipments) { shipmentResponseList.Add(new ShipmentResponse() { DeliveryDate = shipment.DeliveryDate, Departure = shipment.Departure, Destination = shipment.Destination, Orders = shipment.Orders, ShipmentDate = shipment.ShipmentDate, ShipmentID = shipment.ShipmentID }); } return(shipmentResponseList); }
public async Task <ExecutionResult <List <Shipment> > > Handle(GetShipmentsQuery request, CancellationToken cancellationToken) { var shipments = await _applicationDbContext.Shipments.ToListAsync(); return(ExecutionResult <List <Shipment> > .CreateSuccessResult(shipments)); }