public async Task GetLiveWeeksFor_WithRecentlyRegisteredUser_ShouldCallLastFmCorrectly() { // Arrange var context = FakeThreeChartsContext.BuildInMemoryContext(); var repo = new ChartRepository(context); var lastFmMock = new FakeLastFmService(); var chartDateService = new ChartDateService(context); var service = new ChartService(repo, chartDateService, lastFmMock.Object); var userRegisterDate = new DateTime(2020, 4, 21); var endDate = new DateTime(2020, 4, 23, 23, 59, 59); var now = new DateTime(2020, 4, 22); var user = new User { UserName = "******", IanaTimezone = "America/Sao_Paulo", RegisteredAt = userRegisterDate, }; await context.Users.AddAsync(user); await context.SaveChangesAsync(); // Act await service.GetLiveWeekFor(user, now); // Assert lastFmMock.Fake .Verify(lfm => lfm.GetWeeklyTrackChart( It.Is <string>(s => s == "edxds"), It.Is <long>(l => l == new DateTimeOffset(userRegisterDate).ToUnixTimeSeconds()), It.Is <long>(l => l == new DateTimeOffset(endDate).ToUnixTimeSeconds()), It.IsAny <CancellationToken?>())); }
public ChartManager(ChartRepository chartRepository, AlbumRepository albumRepository, PieceRepository pieceRepository, ArtistRepository artistRepository) { this.chartRepository = chartRepository; this.albumRepository = albumRepository; this.pieceRepository = pieceRepository; this.artistRepository = artistRepository; }
public IChart Get(string strChartId, string strDrillBy, string strUserName, string strSearchParameter) { ChartID idSelected; IChart chartToLoad = null; TBL_CHART dbChart = null; ChartRepository cR = null; idSelected = (ChartID)Enum.Parse(typeof(ChartID), strChartId, true); cR = new ChartRepository(); dbChart = cR.GetAll().Where(c => c.ChartID == strChartId && c.IsActive == true).SingleOrDefault(); if (dbChart.TypeOfChart == "Chart") { chartToLoad = new Chart() { BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = idSelected, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs, DrillOverride = false, DrillBy = (string.IsNullOrEmpty(strDrillBy)) ? "" : strDrillBy }; chartToLoad.LoadChart(); chartToLoad.CreateChart(); } else if (dbChart.TypeOfChart == "PieChart") { chartToLoad = new PieChart() { BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = idSelected, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs, DrillOverride = false, DrillBy = (string.IsNullOrEmpty(strDrillBy)) ? "" : strDrillBy }; ((PieChart)chartToLoad).LoadChart(); ((PieChart)chartToLoad).CreateChart(); } else if (dbChart.TypeOfChart == "BarChart") { chartToLoad = new BarChart() { BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = idSelected, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs, DrillOverride = false, DrillBy = (string.IsNullOrEmpty(strDrillBy)) ? "" : strDrillBy }; ((BarChart)chartToLoad).LoadChart(); ((BarChart)chartToLoad).CreateChart(); } return chartToLoad; }
public ChartManager(UnitOfWorkManager unitOfWorkManager) { chartRepository = new ChartRepository(unitOfWorkManager.UnitOfWork); itemManager = new ItemManager(unitOfWorkManager); socialMediaManager = new SocialMediaManager(unitOfWorkManager); zoneManager = new ZoneManager(unitOfWorkManager); CreateStandardChartsIfNotExists(); }
public ActionResult ShowChart() { IEnumerable <Chart> chartData; using (MySqlConnection conn = DBUtils.GetConnection()) { ChartRepository repo = new ChartRepository(conn); chartData = repo.GetAll(); } return(PartialView("ChartView", chartData)); }
public UserController( IUserService userService, ChartRepository chartRepository, IChartService chartService, IChartDateService chartDateService, ILastFmService lastFmService) { _userService = userService; _chartRepository = chartRepository; _chartService = chartService; _chartDateService = chartDateService; _lastFm = lastFmService; }
public Dashboard() { registry = new RepositoryRegistry(); registry.Configure(); accountRepository = RepositoryFactory.GetObject <AccountRepository>(RepositoryId.ACCOUNT_REPOSITORY); cashFlowRepository = RepositoryFactory.GetObject <CashFlowRepository>(RepositoryId.CASHFLOW_REPOSITORY); chartRepository = RepositoryFactory.GetObject <ChartRepository>(RepositoryId.CHART_REPOSITORY); settingRepository = RepositoryFactory.GetObject <SettingRepository>(RepositoryId.SETTING_REPOSITORY); InitializeComponent(); }
public void ChartRepository_Should_AddToBornedCellCountList() { var chartRepository = new ChartRepository(); chartRepository.Should().NotBeNull(); // AddBornedCellCount const int expectedValue = 10; chartRepository.AddBornedCellCount(expectedValue); chartRepository.BornedCellCountList.Count.Should().Be(1); chartRepository.BornedCellCountList[0].Should().Be(expectedValue); }
private void PlotGraphs() { try { ChartID idSelected; IChart chartToLoad; foreach (Control control in Page.Master.FindControl("MainContent").Controls) { if (control.GetType().Name == "ChartLiteral") { SandlerControls.ChartLiteral literalControl = control as SandlerControls.ChartLiteral; literalControl.Text = ""; idSelected = (ChartID)Enum.Parse(typeof(ChartID), literalControl.ID, true); ChartRepository cR = new ChartRepository(); SandlerModels.TBL_CHART dbChart = cR.GetAll().Where(c => c.ChartID == literalControl.ID && c.IsActive == true).SingleOrDefault(); if (dbChart.TypeOfChart == "Chart") { chartToLoad = new Chart() { BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = idSelected, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs }; chartToLoad.LoadChart(CurrentUser); chartToLoad.CreateChart(); literalControl.Text = FusionCharts.RenderChart(@"FusionChartLib/" + ((Chart)chartToLoad).SWF, "", ((Chart)chartToLoad).ChartXML, literalControl.ID, literalControl.Width, literalControl.Height, false, true); } else if (dbChart.TypeOfChart == "PieChart") { chartToLoad = new PieChart() { BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = idSelected, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs }; ((PieChart)chartToLoad).LoadChart(CurrentUser); ((PieChart)chartToLoad).CreateChart(); literalControl.Text = FusionCharts.RenderChart(@"FusionChartLib/" + ((PieChart)chartToLoad).SWF, "", ((PieChart)chartToLoad).ChartXML, literalControl.ID, literalControl.Width, literalControl.Height, false, true); } else if (dbChart.TypeOfChart == "BarChart") { chartToLoad = new BarChart() { BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = idSelected, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs }; ((BarChart)chartToLoad).LoadChart(CurrentUser); ((BarChart)chartToLoad).CreateChart(); literalControl.Text = FusionCharts.RenderChart(@"FusionChartLib/" + ((BarChart)chartToLoad).SWF, "", ((BarChart)chartToLoad).ChartXML, literalControl.ID, literalControl.Width, literalControl.Height, false, true); ; } } } } catch (Exception ex) { throw ex; } }
private async Task <ChartController> CreatChartControllerAsync(IEnumerable <Chart> testData) { await context.Charts.AddRangeAsync(testData); await context.SaveChangesAsync(); var albumRepository = new AlbumRepository(context); var chartRepository = new ChartRepository(context); var artistRepository = new ArtistRepository(context); var pieceRepository = new PieceRepository(context); var service = new ChartManager(chartRepository, albumRepository, pieceRepository, artistRepository); return(new ChartController(service)); }
public async Task <bool> Put([FromBody] ChartEntity chart) { try { IChartRepository <ChartEntity> Respository = new ChartRepository <ChartEntity>(config); await Respository.UpdateItemAsync(chart.id, chart, "Chart"); return(true); } catch { return(false); } }
public async Task <List <ChartEntity> > Post([FromBody] ChartQuery chart) { try { IChartRepository <ChartEntity> Respository = new ChartRepository <ChartEntity>(config); ChartService <ChartEntity> service = new ChartService <ChartEntity>(); if (chart.queryParameter == "findbyuserid") { var charts = await Respository.GetItemsAsync(d => d.userId == chart.userId && d.userId != null && d.isActive == true, "Chart"); return(charts.ToList()); } //else if (chart.queryParameter == "findbydate") //{ // var charts = await Respository.GetItemsAsync(d => d.date == chart.date && d.isActive == true && d.isAvailable == true, "chartMaster"); // return charts.ToList(); //} else { return(await service.CreateItemAsync(chart, config)); //ChartEntity newchart = new ChartEntity(); //newchart.id = null; //newchart.name = chart.name; //newchart.remarks = chart.remarks; //newchart.mailcontent = chart.mailcontent; //newchart.mailsubject = chart.mailsubject; //newchart.userId = chart.userId; //newchart.email = chart.email; //newchart.phone = chart.phone; //newchart.username = chart.username; //newchart.isActive = chart.isActive; //newchart.createdBy = chart.createdBy; //newchart.createdDate = chart.createdDate; //newchart.modifiedBy = chart.modifiedBy; //newchart.modifiedDate = chart.modifiedDate; //newchart.chartAttachments = chart.chartAttachments; //var cht = await Respository.CreateItemAsync(newchart, "Chart"); //List<ChartEntity> chtList = new List<ChartEntity>(); //return chtList; } } catch { List <ChartEntity> chtList = new List <ChartEntity>(); return(chtList); } }
public void ChartRepository_Should_UpdateAgeCountList() { var chartRepository = new ChartRepository(); chartRepository.Should().NotBeNull(); // UpdateAges var actualValue = new List <int>(new[] { 1, 2, 3, 4, 5, 6, 7 }); var expectedValue = new List <int>(new[] { 2, 3, 4, 5, 6, 7 }); chartRepository.UpdateAges(actualValue); chartRepository.AgeCountList.Count.Should().Be(expectedValue.Count); for (var pos = 0; pos < expectedValue.Count; pos++) { chartRepository.AgeCountList[pos].Should().Be(expectedValue[pos]); } }
public ActionResult DeleteElementConfirm(Int64 id /*chart id.*/, Int64 elementId, String returnUrl) { try { if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { ChartRepository.DeleteElementFromChart(elementId, id, GetUserId()); return(Redirect(returnUrl)); } return(RedirectToAction("DataSet", new { id })); } catch (Exception e) { ExceptionMessageToViewBag(e); return(View("Error")); } }
public void ChartRepository_Should_RemoveExtraValuesFromBornedCellCountList(int count) { var chartRepository = new ChartRepository(); chartRepository.Should().NotBeNull(); // AddBornedCellCount const int length = 100; for (var pos = 0; pos < count; pos++) { chartRepository.AddBornedCellCount(pos); } // check BornedCellCount chartRepository.BornedCellCountList.Count.Should().Be(length); chartRepository.BornedCellCountList[0].Should().Be(count - length); chartRepository.BornedCellCountList[length - 1].Should().Be(count - 1); }
public void ChartRepository_Should_Initialize() { var chartRepository = new ChartRepository(); chartRepository.Should().NotBeNull(); chartRepository.TotalCellCountList.Should().NotBeNull(); chartRepository.TotalCellCountList.Count.Should().Be(0); chartRepository.BornedCellCountList.Should().NotBeNull(); chartRepository.BornedCellCountList.Count.Should().Be(0); chartRepository.DiedCellCountList.Should().NotBeNull(); chartRepository.DiedCellCountList.Count.Should().Be(0); chartRepository.AgeCountList.Should().NotBeNull(); chartRepository.AgeCountList.Count.Should().Be(0); }
public UnitOfWork(INavyAccountDbContext context) { this.context = context; Users = new UserRepository(context); Menus = new MenuRepository(context); RoleMenus = new RoleMenuRepository(context); MenuGroups = new MenuGroupRepository(context); UserRoles = new UserRoleRepository(context); FundType = new FundTypeRepo(context); actType = new AccountTypeRepository(context); balSheet = new BalanceSheetRepository(context); mainAccount = new MainAccountRepository(context); accountChart = new ChartRepository(context); subtype = new SubTypeRepository(context); fundTypeCode = new FundTypeRepository(context); loanType = new LoanTypeRepo(context); rank = new RankRepo(context); person = new PersonRepo(context); beneficiary = new BeneficiaryRepo(context); bank = new BankRepository(context); pfundrate = new PfFundRateRepository(context); contribution = new NPFContributionRepository(context); loanRegisterRepository = new LoanRegisterRepository(context); register = new InvestmentRegisterRepository(context); loanStatus = new LoanStatusRepository(context); schedule = new LoanScheduleRepository(context); balance = new TrialBalanceRepository(context); accountHistory = new AccountHistoryRepository(context); npf_Ledgers = new LedgerRepositoy(context); report = new TrialBalanceReportRepository(context); history = new TrialBalanceHistoryRepository(context); pf_loandisc = new LoandiscRepo(context); loanPerRank = new LoanPerRankRepository(context); claimregister = new ClaimRepository(context); npfHistories = new FinancialDocRepo(context); trail = new AuditRailRepository(context); npf_contrdisc = new ContrRepo(context); surplus = new SurplusRepository(context); cam = new ClaimTypeRepository(context); navip = new NavipRepository(context); loantypereview = new LoanTypeReviewRepo(context); }
public IChart Get(string id, string strChartIds, string strChartSubType, string strDrillBy, string strUserName, string strSearchParameter, [System.Web.Http.ModelBinding.ModelBinder] List<ChartParameter> monthYearCombinations) { string[] chartIds = strChartIds.Split(new char[] { '_' }); string chartSubtype = strChartSubType; ChartID idSelected; ChartRepository cR; SandlerModels.TBL_CHART dbChart; IChart chartToLoad = null; UserModel CurrentUser; CurrentUser = new UserModel(strUserName); new UserDataModel().Load(CurrentUser); foreach (string chartId in chartIds) { idSelected = (ChartID)Enum.Parse(typeof(ChartID), chartId, true); cR = new ChartRepository(); dbChart = cR.GetAll().Where(c => c.ChartID == chartId && c.IsActive == true).SingleOrDefault(); if (dbChart.TypeOfChart == "Chart") { chartToLoad = new Chart() { SearchParameter = strSearchParameter, SubType = string.IsNullOrEmpty(chartSubtype) ? ChartSubType.NoSubType : (ChartSubType)Enum.Parse(typeof(ChartSubType), chartSubtype), BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = idSelected, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs, DrillOverride = false, DrillBy = (string.IsNullOrEmpty(strDrillBy)) ? "" : strDrillBy, MonthYearCombinations = monthYearCombinations }; chartToLoad.LoadChart(CurrentUser); chartToLoad.CreateChart(); } else if (dbChart.TypeOfChart == "PieChart") { chartToLoad = new PieChart() { SearchParameter = strSearchParameter, SubType = string.IsNullOrEmpty(chartSubtype) ? ChartSubType.NoSubType : (ChartSubType)Enum.Parse(typeof(ChartSubType), chartSubtype), BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = idSelected, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs, DrillOverride = false, DrillBy = (string.IsNullOrEmpty(strDrillBy)) ? "" : strDrillBy }; ((PieChart)chartToLoad).LoadChart(CurrentUser); ((PieChart)chartToLoad).CreateChart(); } else if (dbChart.TypeOfChart == "BarChart") { chartToLoad = new BarChart() { SearchParameter = strSearchParameter, SubType = string.IsNullOrEmpty(chartSubtype) ? ChartSubType.NoSubType : (ChartSubType)Enum.Parse(typeof(ChartSubType), chartSubtype), BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = idSelected, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs, DrillOverride = false, DrillBy = (string.IsNullOrEmpty(strDrillBy)) ? "" : strDrillBy }; ((BarChart)chartToLoad).LoadChart(CurrentUser); ((BarChart)chartToLoad).CreateChart(); } } return chartToLoad; }
public void ChartRepository_Should_SumValuesFromAgeCountList() { var chartRepository = new ChartRepository(); chartRepository.Should().NotBeNull(); // init array const int arrayLength = 60; const int expectedLength = 50; var expectedValue = new int[arrayLength]; for (var pos = 0; pos < arrayLength; pos++) { expectedValue[pos] = 100 - pos; } // check AgeCount chartRepository.UpdateAges(expectedValue); chartRepository.AgeCountList.Count.Should().Be(expectedLength); chartRepository.AgeCountList[0].Should().Be(100 - 1); chartRepository.AgeCountList[1].Should().Be(100 - 2); chartRepository.AgeCountList[expectedLength - 1].Should().Be(506); }
public IActionResult Get() { var timerManager = new TimerManager(() => _hub.Clients.All.SendAsync("transferchartdata", ChartRepository.GetData())); return(Ok(new { Message = "Request Completed" })); }
public async Task GetStatsForChart_WithMultipleTrackEntries_ReturnsCorrectStats() { // Arrange var lastFmFake = new FakeLastFmService(); var lastFmStub = lastFmFake.Object; // Represents the tracks that will be returned over time var tracksList = new List <List <LastFmChartTrack> > { new List <LastFmChartTrack> { new LastFmChartTrack { Title = "Cool", Artist = "Dua Lipa", Rank = 1 }, new LastFmChartTrack { Title = "Pretty Please", Artist = "Dua Lipa", Rank = 2 }, new LastFmChartTrack { Title = "Hallucinate", Artist = "Dua Lipa", Rank = 3 }, new LastFmChartTrack { Title = "WANNABE", Artist = "ITZY", Rank = 4 }, }, new List <LastFmChartTrack> { new LastFmChartTrack { Title = "WANNABE", Artist = "ITZY", Rank = 1 }, new LastFmChartTrack { Title = "Pretty Please", Artist = "Dua Lipa", Rank = 2 }, new LastFmChartTrack { Title = "Cool", Artist = "Dua Lipa", Rank = 3 }, }, new List <LastFmChartTrack> { new LastFmChartTrack { Title = "WANNABE", Artist = "ITZY", Rank = 1 }, new LastFmChartTrack { Title = "Pretty Please", Artist = "Dua Lipa", Rank = 2 }, new LastFmChartTrack { Title = "Hallucinate", Artist = "Dua Lipa", Rank = 3 }, new LastFmChartTrack { Title = "Cool", Artist = "Dua Lipa", Rank = 4 }, } }; var context = FakeThreeChartsContext.BuildInMemoryContext(); var chartDateService = new ChartDateService(context); var repo = new ChartRepository(context); var chartService = new ChartService(repo, chartDateService, lastFmStub); // Act var weeks = new List <ChartWeek>(); for (var i = 0; i < 3; i++) { var week = new ChartWeek { Owner = new User { UserName = "******" }, WeekNumber = i + 1 }; // Set LastFm fake to return correct tracks according to index lastFmFake.Tracks = tracksList[i]; lastFmFake.SetupFake(); // Updates fake returns var trackChart = await lastFmStub.GetWeeklyTrackChart("", 0, 0); var albumChart = await lastFmStub.GetWeeklyAlbumChart("", 0, 0); var artistChart = await lastFmStub.GetWeeklyArtistChart("", 0, 0); week.ChartEntries = chartService.CreateEntriesForLastFmCharts( trackChart.Value, albumChart.Value, artistChart.Value, week ); weeks.Add(week); } var results = weeks .Select(w => w.ChartEntries) .Select(entries => entries .Select(entry => chartService.GetStatsForChartEntry(entry, weeks)) .ToList()) .ToList(); // Assert // All stats on the first week should be .New results[0].ForEach(r => r.stat.Should().Be(ChartEntryStat.New)); results[1].Should().BeEquivalentTo( new List <(ChartEntryStat stat, string statText)>() { (ChartEntryStat.Increase, "+3"), (ChartEntryStat.NoDiff, "="), (ChartEntryStat.Decrease, "-2"), } ); results[2].Should().BeEquivalentTo( new List <(ChartEntryStat stat, string statText)>() { (ChartEntryStat.NoDiff, "="), (ChartEntryStat.NoDiff, "="), (ChartEntryStat.Reentry, null), (ChartEntryStat.Decrease, "-1"), } ); }
private void PlotFirstIterationGraph() { ChartSubType subType; subType = GetAnalysisSubType(); Session["searchForNewCompany"] = GetNewCompanySelection(); Session["searchCompanies"] = GetCompaniesSelection(); SandlerControls.ChartLiteral chartLiteral = new SandlerControls.ChartLiteral(); chartLiteral.ID = "chartLiteralClosedSalesAnalysis"; chartLiteral.Width = "80%"; chartLiteral.Height = "450"; ChartRepository cR = new ChartRepository(); SandlerModels.TBL_CHART dbChart = cR.GetAll().Where(c => c.ChartID == "ClosedSalesAnalysis" && c.IsActive == true).SingleOrDefault(); Chart chartToLoad = new Chart() { SubType = subType, BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = ChartID.ClosedSalesAnalysis, enableRotation = dbChart.EnableRotation, DrillChartIds = (string.IsNullOrEmpty(dbChart.DrillLevelChartIDs)) ? "" : dbChart.DrillLevelChartIDs, DrillOverride = false, DrillBy = "" }; chartToLoad.LoadChart(CurrentUser); chartToLoad.CreateChart(); chartLiteral.Text = FusionCharts.RenderChart(Page.ResolveClientUrl("~/FusionChartLib/" + chartToLoad.SWF), "", chartToLoad.ChartXML, "ClosedSalesAnalysis", chartLiteral.Width, chartLiteral.Height, false, true); (plotChart.ContentTemplateContainer.FindControl("chartPanel") as Panel).Controls.Add(chartLiteral); }
private void PlotSecondIterationGraph(string chartId, string drillBy, string subType) { SandlerControls.ChartLiteral chartLiteral = new SandlerControls.ChartLiteral(); chartLiteral.ID = "chartLiteralClosedSalesAnalysis"; chartLiteral.Width = "80%"; chartLiteral.Height = "450"; ChartRepository cR = new ChartRepository(); SandlerModels.TBL_CHART dbChart = cR.GetAll().Where(c => c.ChartID == chartId && c.IsActive == true).SingleOrDefault(); PieChart chartToLoad = new PieChart() { SubType = (ChartSubType)Enum.Parse(typeof(ChartSubType), subType), BGAlpha = dbChart.BgAlpha, BGColor = dbChart.BgColor, CanvasBGAlpha = dbChart.CanvasBgAlpha, CanvasBGColor = dbChart.CanvasBgColor, Caption = dbChart.Caption, SWF = dbChart.SWFile, NumberSuffix = dbChart.NumberSuffix, PieRadius = dbChart.PieRadius, showLabels = dbChart.ShowLabels, showLegend = dbChart.ShowLegend, XaxisName = dbChart.XaxisName, YaxisName = dbChart.YaxisName, Id = ChartID.ClosedSalesAnalysisBySource, enableRotation = dbChart.EnableRotation, DrillChartIds = dbChart.DrillLevelChartIDs, DrillOverride = false, DrillBy = drillBy}; chartToLoad.LoadChart(CurrentUser); chartToLoad.CreateChart(); chartLiteral.Text = FusionCharts.RenderChart(Page.ResolveClientUrl("~/FusionChartLib/" + chartToLoad.SWF), "", ((PieChart)chartToLoad).ChartXML, chartLiteral.ID, chartLiteral.Width, chartLiteral.Height, false, true); (plotChart.ContentTemplateContainer.FindControl("chartPanel") as Panel).Controls.Add(chartLiteral); }
public async Task <List <ChartEntity> > CreateItemAsync(ChartQuery chart, IConfiguration _config) { try { BlobStorageService objBlobService = new BlobStorageService(_config); EmailService objEmailService = new EmailService(_config); List <Attachment> attachments = new List <Attachment>(); IChartRepository <ChartEntity> Respository = new ChartRepository <ChartEntity>(_config); ChartEntity newchart = new ChartEntity(); newchart.id = null; newchart.name = chart.name; newchart.remarks = chart.remarks; newchart.mailcontent = chart.mailcontent; newchart.mailsubject = chart.mailsubject; newchart.chartAttachments = chart.chartAttachments; newchart.userId = chart.userId; newchart.email = chart.email; newchart.phone = chart.phone; newchart.username = chart.username; newchart.isActive = chart.isActive; newchart.createdBy = chart.createdBy; newchart.createdDate = chart.createdDate; newchart.modifiedBy = chart.modifiedBy; newchart.modifiedDate = chart.modifiedDate; // add base64 image to blob if (newchart.chartAttachments.Count() > 0) { newchart.chartAttachments.ForEach(x => { string[] strName = x.Name.Split('.'); //x.Path = newchart.userId + "/" + x.uId + "." + strName[strName.Length - 1]; //byte[] bytes = Encoding.ASCII.GetBytes(x.Base64String); // upload to blob //objBlobService.UploadFileToBlob(x.ContainerName, newchart.userId + "/" + x.uId + "." + strName[strName.Length - 1], Encoding.ASCII.GetBytes(x.Base64String), x.ContentType); // add attachments attachments.Add(new Attachment { Content = x.Base64String, Type = x.ContentType, Filename = x.Name, Disposition = "attachment", ContentId = "chart" }); }); } var cht = await Respository.CreateItemAsync(newchart, "Chart"); if (cht != null) { // send Mail var response = objEmailService.SendEmailAsync(newchart.mailsubject, newchart.email, "New Chart from Holistic Fitness", newchart.mailcontent, attachments); } List <ChartEntity> chtList = new List <ChartEntity>(); return(chtList); } catch (Exception ex) { List <ChartEntity> chtList = null; return(chtList); } }
public ArtworkController(ChartRepository repo, IArtworkService artworkService) { _repo = repo; _artworkService = artworkService; }
public ChartsController(ChartRepository chartRepo) { _chartRepo = chartRepo; }
public ChartController(ChartRepository chartRepository, IConfiguration configuration) { _chartRepository = chartRepository; _configuration = configuration; }
public async Task SyncWeeks_WithGenericUser_SavesWeeksCorrectly() { // Arrange var context = FakeThreeChartsContext.BuildInMemoryContext(); var chartDateService = new ChartDateService(context); var lastFmFake = new FakeLastFmService(); var lastFmStub = lastFmFake.Object; lastFmFake.Tracks = new List <LastFmChartTrack> { new LastFmChartTrack { Title = "Cool", Artist = "Dua Lipa", Rank = 1 }, new LastFmChartTrack { Title = "Pretty Please", Artist = "Dua Lipa", Rank = 2 }, new LastFmChartTrack { Title = "Hallucinate", Artist = "Dua Lipa", Rank = 3 }, new LastFmChartTrack { Title = "WANNABE", Artist = "ITZY", Rank = 4 }, }; lastFmFake.SetupFake(); var repo = new ChartRepository(context); var service = new ChartService(repo, chartDateService, lastFmStub); var userRegisterDate = new DateTime(2020, 3, 6); var nowDate = new DateTime(2020, 3, 13); var user = new User() { UserName = "******", RegisteredAt = userRegisterDate }; await context.Users.AddAsync(user); await context.SaveChangesAsync(); // Act await service.SyncWeeks(user, 1, user.RegisteredAt, nowDate, TimeZoneInfo.Utc); // Assert var actualWeeks = await context.ChartWeeks .Where(week => week.OwnerId == user.Id) .ToListAsync(); actualWeeks.Should().HaveCount(1); actualWeeks[0].Owner.Should().BeEquivalentTo(user); actualWeeks[0].From.Should().Be(new DateTime(2020, 3, 6)); actualWeeks[0].To.Should().Be(new DateTime(2020, 3, 12, 23, 59, 59)); actualWeeks[0].ChartEntries.Should().HaveCount(4); for (var i = 0; i < actualWeeks[0].ChartEntries.Count; i++) { // All entries on first week should be new var entry = actualWeeks[0].ChartEntries[i]; var rank = i + 1; entry.Rank.Should().Be(rank); entry.Stat.Should().Be(ChartEntryStat.New); } actualWeeks[0].ChartEntries[0].Title.Should().Be("Cool"); actualWeeks[0].ChartEntries[0].Artist.Should().Be("Dua Lipa"); actualWeeks[0].ChartEntries[1].Title.Should().Be("Pretty Please"); actualWeeks[0].ChartEntries[1].Artist.Should().Be("Dua Lipa"); actualWeeks[0].ChartEntries[2].Title.Should().Be("Hallucinate"); actualWeeks[0].ChartEntries[2].Artist.Should().Be("Dua Lipa"); actualWeeks[0].ChartEntries[3].Title.Should().Be("WANNABE"); actualWeeks[0].ChartEntries[3].Artist.Should().Be("ITZY"); }
public IEnumerable <ChartListItem> GetChart(string name, string date) { return(ChartRepository.GetChart(name, date)); }