public ActionResult <IEnumerable <ProviderSummary> > Get()
        {
            var response = _getProviders.GetAllProviders();

            foreach (var provider in response)
            {
                provider.Uri = Resolve(provider.Ukprn);
            }

            return(response.ToList());
        }
Esempio n. 2
0
        public IEnumerable <ProviderSummary> Get()
        {
            var response = _getProviders.GetAllProviders();

            foreach (var provider in response)
            {
                provider.Uri = Resolve(provider.Ukprn);
            }

            return(response);
        }
        public IEnumerable <Provider> Get()
        {
            try
            {
                var response = _providerRepo.GetAllProviders().Where(x => x.IsDateValid(DateTime.UtcNow)).Select(ApiProviderMapper.Map).ToList();

                foreach (var provider in response)
                {
                    provider.Uri = Resolve(provider.Ukprn);
                }

                return(response);
            }
            catch (Exception e)
            {
                _log.Error(e, "/providers");
                throw;
            }
        }
        public ActionResult Csv()
        {
            var providers = _getProviders.GetAllProviders().Where(x => x.IsDateValid(DateTime.UtcNow) && x.ProviderType != ProviderType.Unknown);
            var date      = _getProviders.GetDateOfProviderList();
            var result    = providers.Select(CsvProviderMapper.Map);

            using (var memoryStream = new MemoryStream())
            {
                using (var streamWriter = new StreamWriter(memoryStream))
                {
                    using (var csvWriter = new CsvWriter(streamWriter))
                    {
                        csvWriter.WriteRecords(result);
                        streamWriter.Flush();
                        memoryStream.Position = 0;
                        return(File(memoryStream.ToArray(), "text/csv", GenerateFilename(date)));
                    }
                }
            }
        }