public async Task <bool> Handle(CreateDeliveryCommand message, CancellationToken cancellationToken)
        {
            var delivery = new Domain.AggregatesModel.DeliveryAggregate.Delivery(message.ClientId, message.Price,
                                                                                 message.Weight, message.Note, _dateTimeFacade.UtcNow);

            delivery.SetPickUpLocation(message.PickUpLocation.GetDeliveryLocation());
            delivery.SetDropOffLocation(message.DropOffLocation.GetDeliveryLocation());

            _logger.LogInformation("----- Creating Delivery: {@Delivery}", delivery);

            _deliveryRepository.Add(delivery);

            return(await _deliveryRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken));
        }
Ejemplo n.º 2
0
 public static DeliveryDto FromDelivery(Domain.AggregatesModel.DeliveryAggregate.Delivery delivery)
 {
     return(new DeliveryDto
     {
         Number = delivery.Number,
         Weight = delivery.Weight,
         CreatedDateTime = delivery.CreatedDateTime,
         FinishedDateTime = delivery.FinishedDateTime,
         Price = delivery.Price,
         Note = delivery.Note,
         DeliveryStatus = delivery.DeliveryStatus,
         ClientId = delivery.GetClientId,
         CourierId = delivery.GetCourierId,
         DropOffLocation = DeliveryLocationDto.FromLocation(delivery.DropOffLocation),
         PickUpLocation = DeliveryLocationDto.FromLocation(delivery.PickUpLocation)
     });
 }
Ejemplo n.º 3
0
 public void Delete(Domain.AggregatesModel.DeliveryAggregate.Delivery delivery)
 {
     _context.Entry(delivery).State = EntityState.Deleted;
 }
Ejemplo n.º 4
0
 public Domain.AggregatesModel.DeliveryAggregate.Delivery Add(
     Domain.AggregatesModel.DeliveryAggregate.Delivery delivery)
 {
     return(_context.Deliveries.Add(delivery).Entity);
 }