public JsonResult GetAllFunds() { FundRepository = new FundRepository(System.Web.HttpContext.Current.Server); var funds = FundRepository.GetFunds(); var total = funds.Count; return Json(new { funds, total}, JsonRequestBehavior.AllowGet); }
public void ExportFilters() { var fundRepository = new FundRepository(); var filterRepository = new BaseXmlRepository<Filter>(); var funds = fundRepository.GetFunds(); var filters = new List<Filter>(); foreach (var prop in typeof(Fund).GetProperties()) { var valuesList = funds.Select(f => prop.GetValue(f, null)) .Distinct() .Where(a=> a != null) .Select(f => new Filter { AttributeName = prop.Name, AttributeValue = f.ToString() }) .ToList(); filters.AddRange(valuesList); //var a = string.Format("{0}={1}", prop.Name, prop.GetValue(funds.First(), null)); } //var list = // funds.Select(f => f.AssetClass) // .Distinct() // .Select(f => new Filter {AttributeName = nameof(Fund.AssetClass), AttributeValue = f}) // .ToList(); filterRepository.Save(filters); Assert.AreNotEqual(0, filters.Count); }
public ActionResult Details(string fundId) { FundRepository = new FundRepository(System.Web.HttpContext.Current.Server); var model = FundRepository.GetFunds().FirstOrDefault(f => f.ExchangeBloombergCode.Equals(fundId)); return View("Details/Details", model); }
public void GetFullFund() { var fundRepository = new FundRepository(); var fundsLinks = this.etfsec.GetFundsLinks(); foreach (var fundLink in fundsLinks) { try { if(fundRepository.GetByFundUrl(fundLink)!=null) continue; //var etfConverter = new EtfConverter(); var etfConverter = this.etfsec.GetSingleFundByLink(fundLink); var fund = etfConverter.Convert(); //fund.FundUrl = fundLink; var sb = new StringBuilder(); sb.AppendLine("Not defined attributes: "); EtfConverter.Attributes.Except(etfConverter.EtfFund.Keys).ForEach(x => sb.Append(x + "; ")); sb.AppendLine(); etfConverter.EtfFund.ForEach(x => sb.AppendLine(x.Key + " : " + x.Value)); sb.AppendLine("Fund url :" + etfConverter.FundUrl); sb.AppendLine("Fund postdata :" + etfConverter.FundPostData); var indexOfLastBackslash = fundLink.LastIndexOf('/'); var fileName = "Results/" + fundLink.Substring(indexOfLastBackslash + 1) + ".xml"; File.WriteAllText(fileName, sb.ToString()); fundRepository.AddOrUpdate(fund); } catch { } } //Assert.IsTrue(fundRepository.GetFunds().Count > 100, "Initial set is not parsed"); Assert.IsTrue(fundRepository.GetFunds().Count > 200, "Full set is not parsed"); }
public void ClearDuplicated() { var fundRepository = new FundRepository(); var funds = fundRepository.GetFunds(); var distinctFUnds = funds .GroupBy(f => f.ExchangeBloombergCode) .Select(g => g.First()) .ToList(); fundRepository.SaveFunds(distinctFUnds); Assert.IsTrue(distinctFUnds.Any()); }