Skip to content
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using AutoMapper;
using FluentResults;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Streetcode.BLL.DTO.AdditionalContent.Subtitles;
using Streetcode.BLL.DTO.Toponyms;
using Microsoft.EntityFrameworkCore;
using Streetcode.BLL.Interfaces.Logging;
using Streetcode.DAL.Repositories.Interfaces.Base;
using AutoMapper.QueryableExtensions;

#pragma warning disable SA1111 //Closing parenthesis should be on line of last parameter
#pragma warning disable SA1513 //Closing brace should be followed by blank line

namespace Streetcode.BLL.MediatR.Toponyms.GetByStreetcodeId;

Expand All @@ -24,21 +27,16 @@

public async Task<Result<IEnumerable<ToponymDTO>>> Handle(GetToponymsByStreetcodeIdQuery request, CancellationToken cancellationToken)
{
var toponyms = await _repositoryWrapper
.ToponymRepository
.GetAllAsync(
predicate: sc => sc.Streetcodes.Any(s => s.Id == request.StreetcodeId),
include: scl => scl
.Include(sc => sc.Coordinate));
toponyms.DistinctBy(x => x.StreetName);
if (toponyms is null)
List<ToponymDTO> toponyms = await _repositoryWrapper.ToponymRepository.FindAll(
sc => sc.Streetcodes.Any(s => s.Id == request.StreetcodeId)
).DistinctBy(t => t.StreetName).ProjectTo<ToponymDTO>(_mapper.ConfigurationProvider).ToListAsync(cancellationToken);

Check warning on line 32 in Streetcode/Streetcode.BLL/MediatR/Toponyms/GetByStreetcodeId/GetToponymsByStreetcodeIdHandler.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Closing parenthesis should not be preceded by a space.

See more on https://sonarcloud.io/project/issues?id=ita-social-projects_StreetCode&issues=AZ4ce1jllz9R9D8Zoh12&open=AZ4ce1jllz9R9D8Zoh12&pullRequest=45

if(toponyms.Count == 0)
{
string errorMsg = $"Cannot find any toponym by the streetcode id: {request.StreetcodeId}";
_logger.LogError(request, errorMsg);
return Result.Fail(new Error(errorMsg));
}

var toponymDto = toponyms.GroupBy(x => x.StreetName).Select(group => group.First()).Select(x => _mapper.Map<ToponymDTO>(x));
return Result.Ok(toponymDto);
return Result.Ok(toponyms.AsEnumerable());
}
}
}
Loading