Пример #1
0
        public async Task <ServiceResult <List <BlogPostResponseModel> > > Get()
        {
            var serviceResult = new ServiceResult <List <BlogPostResponseModel> >();
            var modelList     = new List <BlogPostResponseModel>();

            try
            {
                var list = _blogPostRepository.FindBy(b => b.IsActive && !b.IsDeleted);
                foreach (var item in list)
                {
                    var image = await GetAzureDataById(item.AWSImageId);

                    var model = _mapper.Map <BlogPostResponseModel>(item);
                    model.HeaderImageUrl  = image[0].HeaderImageURL;
                    model.YouTubeVideoURL = image[0].YouTubeVideoURL;
                    modelList.Add(model);
                }

                serviceResult.data       = modelList;
                serviceResult.resultType = ServiceResultType.Success;
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Exception:BlogPost/Get");
                serviceResult.message    = e.Message;
                serviceResult.resultType = ServiceResultType.Fail;
            }

            return(serviceResult);
        }