Example #1
0
        public IEnumerable <RecommendationModel> Get()
        {
            var recommendations = _bankierService.GetRecomendations();

            var companies = recommendations.Select(x => new CompanyDb()
            {
                Name = x.Company,
                Url  = x.CompanyUrl
            }).Distinct();
            var updatedCompanies = _companyRepository.AddRange(companies).Distinct();

            var mappedRecommendations = recommendations.Select(r => new RecommendationDb()
            {
                Company         = updatedCompanies.FirstOrDefault(c => c.Name == r.Company),
                ChangePotential = r.ChangePotential,
                Character       = r.Character,
                Institution     = r.Institution,
                ReleaseDate     = r.ReleaseDate,
                ReleasePrice    = r.ReleasePrice,
                TargetPrice     = r.ReleasePrice
            });

            var recs = _recommendationRepository.AddRange(mappedRecommendations);

            return(recommendations);
        }