/// <summary>
        /// Handles the DeleteServiceRequestByIdCommand.
        /// </summary>
        /// <param name="request">The DeleteServiceRequestByIdCommand being handled.</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The created ServiceRequest entity</returns>
        public async Task <bool> Handle(DeleteServiceRequestByIdCommand request, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Deleting Service Requests By Id {Id} - Request: {@Request}", request.Id, request);

            var serviceRequestToDelete = await _serviceRequestRepository.RetrieveByIdAsync(request.Id);

            if (serviceRequestToDelete is null)
            {
                _logger.LogInformation("Service Request With Id {Id} Not Found - ServiceRequests: {@ServiceRequests}", request.Id, false);

                return(false);
            }

            _serviceRequestRepository.Delete(serviceRequestToDelete);

            _logger.LogInformation("Service Request With Id {Id} Deleted - ServiceRequests: {@ServiceRequests}", request.Id, true);

            return(true);
        }
Ejemplo n.º 2
0
 public void Delete(ServiceRequestDto entity)
 {
     repository.Delete(entity);
 }