public Task <bool> Handle(TakeFreightCommand request, CancellationToken cancellationToken)
        {
            var freightRegister = new FreightsRegister(request.FreightId, request.TruckerId, request.Payment, (int)FreightDeliveryStatus.Pending);

            _freightRegisterRepository.AddFreightRegister(freightRegister);
            _freightRegisterRepository.SaveChanges();
            return(Task.FromResult(true));
        }
        public async Task <bool> Handle(CompleteFreightCommand request, CancellationToken cancellationToken)
        {
            var freightRegister = await _freightsRegisterRepository.GetFreightsByFreightAndTrucker(request.TruckerId, request.FreightId);

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

            freightRegister.ChangeStatus(request.Status);
            if (request.Status == (int)FreightDeliveryStatus.WithIssues)
            {
                var random = new Random();
                freightRegister.AddPayment(freightRegister.Payment - random.Next(100, freightRegister.Payment - 100));
            }
            else if (request.Status == (int)FreightDeliveryStatus.Destroyed)
            {
                freightRegister.AddPayment(0);
            }

            _freightsRegisterRepository.SaveChanges();
            return(true);
        }