Пример #1
0
        // Filtered access: Guest/Admin.
        public async Task <IActionResult> List()
        {
            var models = IsAdmin ? await resService.ListResourcesWithImage(false) : await resService.ListResourcesWithImage(true);

            var dtos = mappService.Map <IEnumerable <ResourceBriefDto> >(models);

            foreach (var item in dtos)
            {
                var images = models.Where(x => x.Id == item.Id).FirstOrDefault().Image
                             .Select(x => x.ImagePath).AsEnumerable();

                item.Image = images;
            }
            return(Ok(dtos));
        }