1

The next api returns in Postmen and to the client item1,item2 While I am using ValueTuple to change the names (the names not so important, but I can’t return item1,item2)

public async Task<(List<CategoryFilterResponseDTO> categoryFilters, string MetaDataDescription)> GetCategoryFilterPage([FromBody]categoryFilterRequestDTO categoryFilterRequest)
{
    var logItem = new LogDTO();
    var result = await _service.GetCategoryFilterPage(categoryFilterRequest);

    try
    {
        OnStart(logItem, new object[] { categoryFilterRequest });
        var categoryFilters = result.categoryFilters;
        var MetaDataDescription = result.MetaDataDescription;


        return (categoryFilters: categoryFilters, MetaDataDescription: MetaDataDescription);

    }
}

the method:

public async Task<(List<CategoryFilterResponseDTO> categoryFilters, string MetaDataDescription)> GetCategoryFilterPage(categoryFilterRequestDTO categoryFilterRequestDTO)
{
    List<CategoryFilterResponseDTO> categoryFilter = new List<CategoryFilterResponseDTO>();
    List<FavoriteDTO> isFavorite = null;
    string MetaDataDescription = "";
    (List<FilterSortDTO<FlatSearchCategory>>, int) searchCategory = await _clubRepo.CategoryFilterPage(categoryFilterRequestDTO);//BranchesCount
    if (searchCategory.Item2 == 0)
    {
        MetaDataDescription = GetCategoryDetails(categoryFilterRequestDTO.CategoryFirstFatherID.Value).CategoryName;
        return (categoryFilters: categoryFilter, MetaDataDescription: MetaDataDescription);
    }
DavidG
  • 113,891
  • 12
  • 217
  • 223
Rachel
  • 33
  • 7

2 Answers2

2

You can change your return to the following:

return Ok(new
{
    categoryFilters = categoryFilter,
    metaDataDescription = MetaDataDescription
});

You will need to change your return type to ActionResult or similar as well.

Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203
Kristofer
  • 675
  • 7
  • 15
1

Because that's the name of the fields on a ValueTuple<,>.

The names given to the values are only available to source code.

Paulo Morgado
  • 14,111
  • 3
  • 31
  • 59