diff --git a/Project.Zap/Controllers/ShiftsController.cs b/Project.Zap/Controllers/ShiftsController.cs index aa98804..4aaca52 100644 --- a/Project.Zap/Controllers/ShiftsController.cs +++ b/Project.Zap/Controllers/ShiftsController.cs @@ -96,13 +96,18 @@ namespace Project.Zap.Controllers locationIds.AddRange(filteredLocations.Select(x => x.id)); } - IEnumerable shifts = await this.shiftRepository.Get( - "SELECT * FROM c WHERE c.StartDateTime >= @startDateTime AND ARRAY_CONTAINS(@locationIds, c.LocationId)", - new Dictionary + string sql = "SELECT * FROM c WHERE c.StartDateTime >= @startDateTime"; + IDictionary parameters = new Dictionary { - { "@startDateTime", search.Start }, - { "@locationIds", locationIds } - }); + { "@startDateTime", search.Start } + }; + + if (locationIds.Any()) + { + sql = sql + " AND ARRAY_CONTAINS(@locationIds, c.LocationId)"; + parameters.Add("@locationIds", locationIds); + } + IEnumerable shifts = await this.shiftRepository.Get(sql, parameters); SearchShiftViewModel viewModel = new SearchShiftViewModel {