diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index 708d96b..98c97de 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -88,6 +88,7 @@ namespace SolarPower.Repository.Implement LEFT JOIN city c ON ps.CityId = c.Id WHERE ps.Id IN @PowerStationIds GROUP BY ps.CityId + ORDER BY c.Priority "; result = (await conn.QueryAsync(sql, new { PowerStationIds = powerStationIds })).ToList(); diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 88a8412..b724770 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -4448,8 +4448,8 @@ namespace SolarPower.Repository.Implement { try { - var sql = $@"SELECT ps.Id AS PowerStationId , ps.`Name` AS PowerStationName,city.Name AS CityName FROM {tableName} ps - LEFT JOIN city ON city.Id = ps.CityId"; + var sql = $@"SELECT ps.Id AS PowerStationId , ps.`Name` AS PowerStationName,c.Name AS CityName FROM {tableName} ps + LEFT JOIN city c ON c.Id = ps.CityId"; if (myUser.Role.Layer == 2) { @@ -4465,6 +4465,8 @@ namespace SolarPower.Repository.Implement { sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')"; } + + sql += " ORDER BY c.Priority"; result = (await conn.QueryAsync(sql, new { CompanyId = myUser.CompanyId, UserId = myUser.Id, Filter = filter })).ToList(); } catch (Exception exception) @@ -4482,14 +4484,16 @@ namespace SolarPower.Repository.Implement { try { - var sql = @$"SELECT ps.Id AS PowerStationId , ps.`Name` AS PowerStationName,city.Name AS CityName FROM {tableName} ps - LEFT JOIN city ON city.Id = ps.CityId WHERE ps.Deleted = 0"; + var sql = @$"SELECT ps.Id AS PowerStationId , ps.`Name` AS PowerStationName,c.Name AS CityName FROM {tableName} ps + LEFT JOIN city c ON c.Id = ps.CityId WHERE ps.Deleted = 0 "; if (!string.IsNullOrEmpty(filter)) { sql += @" AND ps.Name LIKE CONCAT('%', @Filter, '%')"; } + + sql += " ORDER BY c.Priority"; result = (await conn.QueryAsync(sql, new { Filter = filter })).ToList(); } catch (Exception exception)