コード例 #1
0
        public async Task <bool> Handle(AcceptLeaveCommand request, CancellationToken cancellationToken)
        {
            // Add/Update the Leave AggregateRoot
            // DDD patterns comment: Add child entities and value-objects through the Order Aggregate-Root
            // methods and constructor so validations, invariants and business logic
            // make sure that consistency is preserved across the whole aggregate


            // Recupera el los LeaveType para comprobar que es un ID correcto, se ha hecho solo a modo de ejemplo, se podría hacer lo mismo para el ResourceId
            var leave = await _leaveRepository.GetAsync(request.LeaveId);

            if (leave == null)
            {
                return(false);
            }

            leave.SetAcceptedStatus();
            return(await _leaveRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken));
        }
コード例 #2
0
        public async Task Handle(LeaveAcceptedDomainEvent leaveAcceptedDomainEvent, CancellationToken cancellationToken)
        {
            //_logger.CreateLogger<OrderCancelledDomainEvent>()
            //   .LogTrace("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})",
            //       orderCancelledDomainEvent.Order.Id, nameof(OrderStatus.Cancelled), OrderStatus.Cancelled.Id);

            // Añade la notificación del cambio de estado del Leave a la entidad Resource
            var leave = await _leaveRepository.GetAsync(leaveAcceptedDomainEvent.Leave.Id);

            if (leave != null)
            {
                var resource = await _resourceRepository.FindByIdAsync(leave.GetResourceId != null?leave.GetResourceId.ToString() : "0");

                resource.AddResourceNotification(leave.Id);
            }

            //var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString());

            //var orderStatusChangedToCancelledIntegrationEvent = new OrderStatusChangedToCancelledIntegrationEvent(order.Id, order.OrderStatus.Name, buyer.Name);
            //await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedToCancelledIntegrationEvent);
        }
コード例 #3
0
 public async Task <LeaveModel> GetMeAsync(int id)
 {
     return(_leaveMapper.ConvertToModel(await _leaveRepository.GetAsync(id)));
 }