public List <NomenclatureDTO> GetGoods(CatalogType type) { using (var uow = UnitOfWorkFactory.CreateWithoutRoot($"[MB]Получение каталога товаров {type}")) { var types = Enum.GetValues(typeof(MobileCatalog)) .Cast <MobileCatalog>() .Where(x => x.ToString().StartsWith(type.ToString())) .ToArray(); var list = _nomenclatureRepository.GetNomenclatureWithPriceForMobileApp(uow, types); if (type == CatalogType.Water) { list = list.OrderByDescending(n => n.Weight) .ThenBy(n => n.NomenclaturePrice.Any() ? n.NomenclaturePrice.Max(p => p.Price) : 0) .ToList(); } else { list = list.OrderBy(n => (int)n.MobileCatalog) .ThenBy(n => n.NomenclaturePrice.Any() ? n.NomenclaturePrice.Max(p => p.Price) : 0) .ToList(); } var listDto = list.Select(n => new NomenclatureDTO(n)).ToList(); var imageIds = _nomenclatureRepository.GetNomenclatureImagesIds(uow, list.Select(x => x.Id).ToArray()); listDto.Where(dto => imageIds.ContainsKey(dto.Id)) .ToList() .ForEach(dto => dto.imagesIds = imageIds[dto.Id]); return(listDto); } }