/// <inheritdoc/> public async Task <ServiceExecuteResult <IEnumerable <Category> > > GetCategories() { try { var categories = ( await _repository.GetCategories(isGetOnlyVisible: false) ) .OrderBy(x => x.Alias) .ToList(); foreach (var category in categories) { category.Photos = category.Photos.OrderBy(x => x.Date).ToList(); } return(new ServiceExecuteResult <IEnumerable <Category> > { IsSuccess = true, Result = categories }); } catch (Exception ex) { var msg = $"Не удалось получить список категорий. ${ex.Message}"; _logger.LogError(ex, msg); return(new ServiceExecuteResult <IEnumerable <Category> > { IsSuccess = false, Error = msg }); } }
public async Task <IActionResult> GetCategories() { var result = (await _repository.GetCategories(isGetOnlyVisible: true)) .OrderBy(x => x.Alias); foreach (var category in result) { category.Photos = category.Photos.OrderBy(x => x.Date).ToList(); } return(Success(result)); }