refactor(search): treat empty search strings as no filter (string.IsNullOrEmpty)
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Musify.Application.PlayLists
|
||||
.AsNoTracking()
|
||||
.Where(p => p.UserId == request.UserId);
|
||||
|
||||
if (request.Name is not null)
|
||||
if (!string.IsNullOrEmpty(request.Name))
|
||||
{
|
||||
var normalizedName = request.Name.Trim().ToUpperInvariant();
|
||||
playListsQuery = playListsQuery.Where(p => p.NormalizedName.Contains(normalizedName));
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Musify.Application.Tracks
|
||||
.Include(ut => ut.Track)
|
||||
.AsQueryable();
|
||||
|
||||
if (request.Name is not null)
|
||||
if (!string.IsNullOrEmpty(request.Name))
|
||||
{
|
||||
var normalizedName = request.Name.Trim().ToUpperInvariant();
|
||||
tracksQuery = tracksQuery.Where(t => t.Track.NormalizedTitle.Contains(normalizedName));
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Musify.Application.Tracks
|
||||
.Include(ut => ut.Track)
|
||||
.Where(p => p.UserId == request.UserId);
|
||||
|
||||
if (request.Name is not null)
|
||||
if (!string.IsNullOrEmpty(request.Name))
|
||||
{
|
||||
var normalizedName = request.Name.Trim().ToUpperInvariant();
|
||||
tracksQuery = tracksQuery.Where(t => t.Track.NormalizedTitle.Contains(normalizedName));
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Musify.Application.Users
|
||||
.AsNoTracking()
|
||||
.AsQueryable();
|
||||
|
||||
if (request.UsernameSearch is not null)
|
||||
if (!string.IsNullOrEmpty(request.UsernameSearch))
|
||||
{
|
||||
var normalizedUsername = request.UsernameSearch.Trim().ToUpperInvariant();
|
||||
user = user.Where(u => u.NormalizedName.Contains(normalizedUsername));
|
||||
|
||||
Reference in New Issue
Block a user