public async Task <CreateMoodRecordResponse> RunAsync <T>(T request, CancellationToken token) { _logger.LogTrace($"{nameof(RunAsync)} in {nameof(CreateMoodRecordService)} running."); if (request is not MoodRecord moodRecord) { _logger.LogError( $"{nameof(request)} with body: {JsonSerializer.Serialize(request)} " + $"is not of type {typeof(CreateMoodRecordCommand)}"); throw new ArgumentException($"{nameof(request)} is not of type {typeof(CreateMoodRecordCommand)}"); } var response = await _mongoDbRepository.CreateAsync(MoodRecordMapper.GetDto(moodRecord)); return(new CreateMoodRecordResponse(true, response)); }