public async Task <Unit> Handle(DeleteJobOfferCommand request, CancellationToken cancellationToken) { var entity = await _jobOfferRepository.GetByIdAsync(request.Id); if (entity == null) { _logger.LogWarning("Entity not found from database. Request ID: {0}", request.Id); throw new NotFoundException(nameof(JobOffer), request.Id); } var userOwns = await _jobOfferRepository.UserOwnsEntityAsync(request.Id, _currentUserService.UserId); if (!userOwns) { _logger.LogWarning("User is not own for this entity, Id: {0}, UserId: {1}", request.Id, _currentUserService.UserId); throw new ForbiddenAccessException(nameof(JobOffer), request.Id); } await _jobOfferRepository.DeleteAsync(entity); _logger.LogInformation("Deleted JobOffer Id: {0}", entity.Id); return(Unit.Value); }