diff --git a/Distribution/Features/DeliveryRide/DeliveryTaskService.cs b/Distribution/Features/DeliveryRide/DeliveryTaskService.cs index 265ef1f..45f4493 100644 --- a/Distribution/Features/DeliveryRide/DeliveryTaskService.cs +++ b/Distribution/Features/DeliveryRide/DeliveryTaskService.cs @@ -187,9 +187,9 @@ public class DeliveryTaskService( repo.Update(task); orderRepo.Update(order); - if (fullyDelivered) + if (fullyDelivered && order.FK_SaleId is Guid saleId) { - var sale = await saleRepo.GetByIdAsync(order.FK_SaleId) + var sale = await saleRepo.GetByIdAsync(saleId) ?? throw new KeyNotFoundException("Sale not found"); sale.Status = SaleStatus.Completed; sale.CompletedAt = DateTime.Now;