Prevents to query the database if the requested culture is null or empty

This commit is contained in:
Hermes Sbicego 2023-09-15 08:49:26 +02:00 committed by GitHub
parent 95cd4c0fb5
commit d18b9e93e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
@ -87,9 +87,12 @@ namespace Orchard.Localization.Services {
});
}
public CultureRecord GetCultureByName(string cultureName) {
if (string.IsNullOrWhiteSpace(cultureName)) {
return null;
}
var cultures = GetAllCulturesByName();
CultureRecord result;
cultures.TryGetValue(cultureName ?? "", out result);
cultures.TryGetValue(cultureName, out result);
return result;
}