public async Task <TaxDto> GetTax(SearchTaskDto search) { if (string.IsNullOrEmpty(search.MunicipalityName)) { return(null); } var taxes = await _textRepository .GetTaxByCityAsync(search.MunicipalityName, search.Date); return(taxes.OrderByDescending(x => x.TaxType).First()); /*Fixed code there and in the repository */ }