public async Task <ServiceRequest> Handle(UpdateServiceRequestByIdCommand request, CancellationToken cancellationToken) { _logger.LogInformation("Updating Service Requests By Id {Id} - Request: {@Request}", request.Id, request); var serviceRequest = await _serviceRequestRepository.RetrieveByIdAsync(request.Id); if (serviceRequest is null) { _logger.LogInformation("Service Request With Id {Id} Not Found - ServiceRequests: {@ServiceRequests}", request.Id, false); return(null); } // Let the ServiceRequestAggregate handle the business logic behind updating the fields. serviceRequest.SetLastModifiedBy(request.RequestBody.ModifiedBy); serviceRequest.SetLastModifiedDate(DateTime.UtcNow); serviceRequest.SetBuildingCode(request.RequestBody.BuildingCode); serviceRequest.SetDescription(request.RequestBody.Description); serviceRequest.SetCurrentStatus(request.RequestBody.CurrentStatus); _serviceRequestRepository.Update(serviceRequest); _logger.LogInformation("Service Request With Id {Id} Deleted - ServiceRequests: {@ServiceRequests}", request.Id, true); return(serviceRequest); }