public ProcessResult <List <DashboardResponse> > Buscar(DashboardRequest filtro) { ProcessResult <List <DashboardResponse> > resultado = new ProcessResult <List <DashboardResponse> >(); try { List <DashboardLogic> lista = LogicRepository.Buscar( filtro.CodigoIdioma, filtro.CodigoIndicador, filtro.TipoDashboard, filtro.Anio, filtro.Fecha, filtro.TipoPeriodicidad, filtro.CodigoSubTipoPeriodicidad); resultado.Result = new List <DashboardResponse>(); foreach (DashboardLogic item in lista) { DashboardResponse Response = DashboardAdapter.ObtenerListado(item); resultado.Result.Add(Response); } } catch (Exception ex) { resultado.IsSuccess = false; resultado.Exception = new ApplicationLayerException <DashboardService>(ex); } return(resultado); }
protected override void WriteResponse(DashboardResponse response) { foreach (var resourceName in _resourceNames) { WriteResource(response, _assembly, $"{_baseNamespace}.{resourceName}"); } }
public DashboardResponse Transactions(DashboardRequest objRequest) { try { if (objRequest.DashboardType == 16) { objDashboardResponse.DashboardGrid = objclsDashboard.GetAEPS_RUPAYTransactions(objRequest.TransactionType, objRequest.DateTime); } else if (objRequest.DashboardType == 17) { objDashboardResponse.DashboardGrid = objclsDashboard.GetAEPSISSUERTransactions(objRequest.DateTime); } else { objDashboardResponse.DashboardGrid = objclsDashboard.GetTransactions(objRequest.DashboardType, objRequest.DateTime); } return(objDashboardResponse); } catch (Exception) { return(objDashboardResponse); } finally { objDashboardResponse = null; objclsDashboard = null; } }
public async Task <IHttpActionResult> GetData() { var data = new DashboardResponse { Users = await userService.GetDashboardUsersAsync() }; return(Ok(data)); }
public async Task <IActionResult> GetDashboard() { DashboardResponse response = await _storage.GetDashboardOverview(); response.DHCPv6.ScopeAmount = _rootScope.GetTotalAmountOfScopes(); response.DHCPv4.ScopeAmount = _dhcpv4RootScope.GetTotalAmountOfScopes(); response.AmountOfPipelines = _notificationEngine.GetPipelineAmount(); return(base.Ok(response)); }
public DashboardResponse GetDashboard() { DashboardResponse response = new DashboardResponse(); response.TotalCustomers = _context.Customers.Count(); response.TotalUsers = _context.Users.Count(); response.TotalSales = _context.Sales.Count(); return(response); }
protected override async Task WriteResponse(DashboardResponse response) { foreach (var resourceName in _resourceNames) { await WriteResource( response, _assembly, $"{_baseNamespace}.{resourceName}").ConfigureAwait(false); } }
protected async Task WriteResource(DashboardResponse response, Assembly assembly, string resourceName) { using (var inputStream = assembly.GetManifestResourceStream(resourceName)) { if (inputStream == null) { throw new ArgumentException($@"Resource with name {resourceName} not found in assembly {assembly}."); } await inputStream.CopyToAsync(response.Body).ConfigureAwait(false); } }
private static async Task WriteResourceAsync(DashboardResponse response, Assembly assembly, string resourceName) { using (var stream = assembly.GetManifestResourceStream(resourceName)) { if (stream == null) { throw new ArgumentException($@"Resource '{resourceName}' not found in assembly {assembly}."); } await stream.CopyToAsync(response.Body); } }
protected void WriteResource(DashboardResponse response, Assembly assembly, string resourceName) { using (var inputStream = assembly.GetManifestResourceStream(resourceName)) { if (inputStream == null) { throw new ArgumentException($@"Resource with name {resourceName} not found in assembly {assembly}."); } inputStream.CopyTo(response.Body); } }
protected override async Task WriteResponse(DashboardResponse response) { foreach (var resourceName in _resourceNames) { var nameBytes = new UTF8Encoding().GetBytes($"\n\r/* {resourceName} */\n\r"); await response.Body.WriteAsync(nameBytes, 0, nameBytes.Length).ConfigureAwait(false); await WriteResource( response, _assembly, $"{_baseNamespace}.{resourceName}").ConfigureAwait(false); } }
public async Task <DashboardResponse> GetDashboardData() { var dashboardResponse = new DashboardResponse(); var companies = sqlProvider.GetCompaniesAsync(); var departments = sqlProvider.GetDepartmentsAsync(); var employees = sqlProvider.GetEmployeesAsync(); dashboardResponse.Companies = await companies; dashboardResponse.Departments = await departments; dashboardResponse.Employees = await employees; return(dashboardResponse); }
public Task Dispatch(DashboardContext context) { DashboardRequest request = context.Request; DashboardResponse response = context.Response; if (!"POST".Equals(request.Method, StringComparison.OrdinalIgnoreCase)) { response.StatusCode = 405; return((Task)Task.FromResult <bool>(false)); } this._command(context); return((Task)Task.FromResult <bool>(true)); }
public DashboardResponse GetSurveyDashboardInfo(string SurveyId) { DashboardResponse DashboardResponse = new DashboardResponse(); _surveyInfoRequest.Criteria.SurveyIdList = new List <string>(); _surveyInfoRequest.Criteria.SurveyIdList.Add(SurveyId); var ListDTO = _iSurveyInfoRepository.GetSurveyInfo(_surveyInfoRequest).SurveyInfoList; if (ListDTO.Count() > 0) { DashboardResponse.SurveyInfo = ListDTO[0]; } DashboardResponse = _iSurveyAnswerRepository.GetSurveyDashboardInfo(SurveyId); return(DashboardResponse); }
public DashboardResponse GetSurveyDashboardInfo(string surveyid) { DashboardResponse DashboardResponse = new DashboardResponse(); SurveyDashboardBO SurveyDashboardBO = new SurveyDashboardBO(); SurveyDashboardBO = SurveyResponseDao.GetSurveyDashboardCounts(surveyid); DashboardResponse.SurveyInfo = Mapper.ToSurveyInfoDTO(SurveyInfoDao.GetDashboardSurveyInfo(surveyid)); DashboardResponse.SavedRecordCount = SurveyDashboardBO.SavedRecordCount; DashboardResponse.StartedRecordCount = SurveyDashboardBO.StartedRecordCount; DashboardResponse.SubmitedRecordCount = SurveyDashboardBO.SubmitedRecordCount; DashboardResponse.RecordCount = SurveyDashboardBO.RecordCount; DashboardResponse.RecordCountPerDate = SurveyDashboardBO.RecordCountPerDate; DashboardResponse.DownloadedRecordCount = SurveyDashboardBO.DownloadedRecordCount; return(DashboardResponse); }
public DashboardResponse GetSurveyDashboardInfo(string surveyid) { DashboardResponse DashboardResponse = new DashboardResponse(); Epi.Web.Interfaces.DataInterfaces.ISurveyResponseDao SurveyResponseDao = new EF.EntitySurveyResponseDao(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyDashboardInfo Implementation = new Epi.Web.BLL.SurveyDashboardInfo(SurveyResponseDao, ISurveyInfoDao); try { return(Implementation.GetSurveyDashboardInfo(surveyid)); } catch (Exception ex) { return(null); throw ex; } }
public DashboardResponse ProcessDashboardRequest(DashboardRequest objRequest) { try { objDashboardResponse.DashboardType = objRequest.DashboardType; objDashboardResponse.DashboardGrid = objclsDashboard.GetDashboard(objRequest.DashboardType, objRequest.DateTime); return(objDashboardResponse); } catch (Exception) { return(objDashboardResponse); } finally { objDashboardResponse = null; objclsDashboard = null; } }
protected async Task WriteResource(DashboardResponse response, string filePath) { var fileInfo = _fileProvider.GetFileInfo(filePath); if (!fileInfo.Exists) { throw new ArgumentException($@"Could not find file '{fileInfo.PhysicalPath}'"); } using (var readStream = fileInfo.CreateReadStream()) { if (readStream == null) { throw new ArgumentException($@"Resource with name {filePath} not found."); } // await readStream.CopyToAsync(response.Body).ConfigureAwait(false); // Larger StreamCopyBufferSize is required because in case of FileStream readStream isn't going to be buffering await StreamCopyOperation.CopyToAsync(readStream, response.Body, fileInfo.Length, StreamCopyBufferSize, CancellationToken.None); } }
public static DashboardResponse ObtenerListado(DashboardLogic Logic) { DashboardResponse Response = new DashboardResponse(); Response.CodigoIndicador = Logic.CodigoIndicador; Response.Anio = Logic.Anio; Response.Fecha = Logic.Fecha; Response.TipoPeriodicidad = Logic.TipoPeriodicidad; Response.Indicador = Logic.Indicador; Response.Ponderacion = Logic.Ponderacion; Response.Valor = Logic.Valor; //Obligatorios Response.EstadoRegistro = Logic.EstadoRegistro; Response.NumeroFila = Logic.NumeroRegistro; Response.FilasTotal = Logic.TotalRegistro; return(Response); }
public DashboardResponse dashboardDetails() { DashboardResponse SR = new DashboardResponse(); List <VSR_Trn_ServiceEntry_GetDashboardData_Result> dash = new List <VSR_Trn_ServiceEntry_GetDashboardData_Result>(); try { dash = db.VSR_Trn_ServiceEntry_GetDashboardData().ToList(); if (dash.Count() > 0) { SR.status = 1; SR.dashDetails = dash; } return(SR); } catch { SR.dashDetails = dash; SR.status = 0; return(SR); } }
public async Task Dispatch(DashboardContext context) { DashboardRequest request = context.Request; DashboardResponse response = context.Response; if (!"POST".Equals(request.Method, StringComparison.OrdinalIgnoreCase)) { response.StatusCode = 405; //return (Task)Task.FromResult<bool>(false); } if (await this._command(context)) { response.ContentType = "application/json"; response.StatusCode = (int)HttpStatusCode.OK; } else { response.StatusCode = 422; } //return (Task)Task.FromResult<bool>(true); }
/// <summary> /// Need to return DashboardRequest object /// </summary> /// <param name="rssIssues"></param> /// <returns></returns> public static DashboardResponse ToPhoneModel(IEnumerable<RssIssue> issues, int issueage) { if (issues == null) { throw new Exception("issues == null"); } DashboardResponse response = new DashboardResponse(); //List<DashboardItem> List<DashboardItem> listDashboardItems = (from issue in issues select new DashboardItem() { FeedDefintion = new AzureDashboardService.RssFeed { ServiceName = issue.RssFeed.ServiceName, RegionLocation = issue.RssFeed.LocationName, FeedCode = issue.RssFeed.FeedCode, RSSLink = issue.RssFeed.RSSLink } , FeedIssues = (from channel in issue.RssIssueXml.channel where channel.item != null from item in channel.item where DateTimeConversion.FromRssPubDateToDateTime(item.pubDate) >= DateTime.UtcNow.AddDays(-issueage) select new RSSFeedItemDetail { Title = item.title, Description = item.description, PubDate = item.pubDate, Status = item.status }).ToList() } ).ToList(); response.List = listDashboardItems; return response; }
/// <summary> /// Get Dashboard Data async /// </summary> /// <param name=""></param> /// <param name=""></param> /// <returns></returns> public async Task <Response <List <DashboardResponse> > > GetDashboardDataAsync() { try { IEnumerable <Dashboard> dashboard = await _chatbotDataContext.Dashboard.FromSql("icb.usp_DashboardGetReportData").ToListAsync(); DashboardResponse dashboardResponse = new DashboardResponse(); IEnumerable <string> chartLabels = dashboard.Select(x => x.InterviewMonth).Distinct(); dashboardResponse.ChartLabel.AddRange(chartLabels); foreach (string technologyStack in dashboard.Select(x => x.TechnologyStackDisplayName).Distinct()) { ChartDataSet chartDataSet = new ChartDataSet { Label = technologyStack }; foreach (string interviewMonth in dashboard.Select(x => x.InterviewMonth).Distinct()) { chartDataSet.Data.AddRange ( dashboard.Where(x => x.TechnologyStackDisplayName == technologyStack && x.InterviewMonth == interviewMonth) .Select(x => x.MonthlyInterviewCount) ); } dashboardResponse.ChartDataSet.Add(chartDataSet); } return(Response.Ok(new List <DashboardResponse> { dashboardResponse })); } catch (Exception) { return(Response.Fail <List <DashboardResponse> >("Something went wrong", ResponseType.GenericError)); } }
public async Task <DashboardResponse> Get() { var lastMonth = DateTime.Today.AddMonths(-1); var today = DateTime.Today; var expenses = await _expensesProvider.GetExpenses(lastMonth.Month, lastMonth.Year); var invoices = await _invoicesProvider.GetInvoice(lastMonth.Month, lastMonth.Year); // Przychód netto bez odliczeń var grossIncome = invoices.Sum(x => x.NetSum); // Koszt uzyskania przychodu var incomeCosts = expenses.Sum(x => x.NetAmount); // Pit do zapłaty var payablePit = (grossIncome - incomeCosts) * PitPercent / 100; var vat = invoices.Sum(x => x.VatSum); // Vat do zapłaty var payableVat = vat - expenses.Sum(x => x.VatAmount); var dashboardResponse = new DashboardResponse { GrossIncome = grossIncome, PayablePit = payablePit > 0 ? payablePit : 0, PayableVat = payableVat > 0 ? payableVat : 0, StartOfSettlingPeriod = new DateTime(lastMonth.Year, lastMonth.Month, 1), EndOfSettlingPeriod = new DateTime(lastMonth.Year, lastMonth.Month, DateTime.DaysInMonth(lastMonth.Year, lastMonth.Month)), VatSettlementDate = new DateTime(today.Year, today.Month, 25), PitSettlementDate = new DateTime(today.Year, today.Month, 20) }; return(dashboardResponse); }
protected virtual Task WriteResponse(DashboardResponse response) { return(WriteResource(response, _filePath)); }
protected virtual Task WriteResponse(DashboardResponse response) { return(WriteResource(response, _assembly, _resourceName)); }
public DashboardResponse GetDashboardData() { var cutDayForActivity = Data.GetDateTimeNow().AddDays(-7); var advisors = AdvisorBusiness.ListAllAdvisors(); var users = Task.Factory.StartNew(() => UserBusiness.ListAllUsersData()); var advisorFollowers = Task.Factory.StartNew(() => FollowAdvisorBusiness.ListFollowers(advisors.Select(c => c.Id).Distinct(), false)); var assetFollowers = Task.Factory.StartNew(() => FollowAssetBusiness.ListFollowers()); var activities = Task.Factory.StartNew(() => Data.FilterActivity(cutDayForActivity, ActionType.NewAucVerification, ActionType.NewLogin)); Task.WaitAll(users, advisorFollowers, assetFollowers, activities); var adminsId = users.Result.Where(c => Admins?.Any(a => a == c.Email) == true).Select(c => c.Id).ToHashSet(); var consideredUsers = users.Result.Where(c => !adminsId.Contains(c.Id) && (!c.ReferredId.HasValue || !adminsId.Contains(c.ReferredId.Value))).ToList(); var consideredAdvisors = advisors.Where(c => !adminsId.Contains(c.Id) && (!c.ReferredId.HasValue || !adminsId.Contains(c.ReferredId.Value))).ToList(); var consideredAdvisorFollowers = advisorFollowers.Result.Where(c => consideredUsers.Any(u => u.Id == c.UserId)).ToList(); var consideredAssetFollowers = assetFollowers.Result.Where(c => consideredUsers.Any(u => u.Id == c.UserId)).ToList(); var consideredActivities = activities.Result.Where(c => consideredUsers.Any(u => u.Id == c.UserId)).ToList(); var result = new DashboardResponse(); result.TotalUsersConfirmed = consideredUsers.Count(c => c.Wallets.Any()); result.TotalUsersConfirmedFromReferral = consideredUsers.Count(c => c.ReferredId.HasValue && c.Wallets.Any()); result.TotalUsersStartedRegistration = consideredUsers.Count(c => !consideredAdvisors.Any(a => a.Id == c.Id) && !c.Wallets.Any()); result.TotalUsersStartedRegistrationFromReferral = consideredUsers.Count(c => c.ReferredId.HasValue && !consideredAdvisors.Any(a => a.Id == c.Id) && !c.Wallets.Any()); result.TotalAdvisors = consideredAdvisors.Count; result.TotalActiveUsers = consideredActivities.Any() ? consideredActivities.Select(c => c.UserId).Distinct().Count(c => !consideredAdvisors.Any(a => a.Id == c) && consideredUsers.Any(u => u.Id == c && u.Wallets.Any())) : 0; result.TotalWalletsInProgress = consideredUsers.Count(c => c.ReferralStatusType == ReferralStatusType.InProgress); result.TotalFollowing = consideredAdvisorFollowers.Count + consideredAssetFollowers.Count; result.TotalAdvisorsFollowed = consideredAdvisorFollowers.Any() ? consideredAdvisorFollowers.Select(c => c.AdvisorId).Distinct().Count() : 0; result.TotalUsersFollowing = consideredAdvisorFollowers.Any() || consideredAssetFollowers.Any() ? consideredAdvisorFollowers.Select(c => c.UserId).Concat(consideredAssetFollowers.Select(c => c.UserId)).Distinct().Count() : 0; var confirmedUsers = new Dictionary <int, DateTime>(); foreach (var user in consideredUsers.Where(c => c.Wallets.Any())) { if (!consideredAdvisors.Any(c => c.Id == user.Id)) { confirmedUsers[user.Id] = user.Wallets.OrderBy(c => c.CreationDate).First().CreationDate; } var currentWallet = user.Wallets.OrderByDescending(c => c.CreationDate).First(); result.TotalWalletsWithAuc += currentWallet.AUCBalance > 0 ? 1 : 0; result.AucHolded += Convert.ToDouble(currentWallet.AUCBalance ?? 0); result.AucHoldedInProgress += user.ReferralStatusType == ReferralStatusType.InProgress ? Convert.ToDouble(currentWallet.AUCBalance ?? 0) : 0; } result.AucRatioPerConfirmedUser = result.TotalUsersConfirmed > 0 ? result.AucHolded / result.TotalUsersConfirmed : 0; result.AucRatioPerUserInProgress = result.TotalWalletsInProgress > 0 ? result.AucHoldedInProgress / result.TotalWalletsInProgress : 0; var usersConfirmedData = !confirmedUsers.Any() ? null : confirmedUsers.GroupBy(c => c.Value.ToString("yyyy-MM-dd")) .Select(g => new DashboardResponse.RegistrationData() { Date = DateTime.Parse(g.Key), Value = g.Count() }).OrderBy(c => c.Date); var advisorsData = !consideredAdvisors.Any() ? null : consideredAdvisors.GroupBy(c => c.BecameAdvisorDate.ToString("yyyy-MM-dd")) .Select(g => new DashboardResponse.RegistrationData() { Date = DateTime.Parse(g.Key), Value = g.Count() }).OrderBy(c => c.Date); var usersStartedRegistrationData = !consideredUsers.Any(c => !consideredAdvisors.Any(a => a.Id == c.Id) && !c.Wallets.Any()) ? null : consideredUsers.Where(c => !consideredAdvisors.Any(a => a.Id == c.Id) && !c.Wallets.Any()).GroupBy(c => c.CreationDate.ToString("yyyy-MM-dd")) .Select(g => new DashboardResponse.RegistrationData() { Date = DateTime.Parse(g.Key), Value = g.Count() }).OrderBy(c => c.Date); var minDate = GetMinDate(usersConfirmedData, advisorsData, usersStartedRegistrationData); result.UsersConfirmed = GetRegistrationData(usersConfirmedData, minDate); result.Advisors = GetRegistrationData(advisorsData, minDate); result.UsersStartedRegistration = GetRegistrationData(usersStartedRegistrationData, minDate); result.UsersConfirmedLastSitutation = GetFlagData(result.UsersConfirmed); result.AdvisorsLastSitutation = GetFlagData(result.Advisors); result.UsersStartedRegistrationLastSitutation = GetFlagData(result.UsersStartedRegistration); result.UsersConfirmed.Add(new DashboardResponse.RegistrationData() { Date = Data.GetDateTimeNow().Date.AddDays(1), Value = result.UsersConfirmed.LastOrDefault()?.Value ?? 0 }); result.Advisors.Add(new DashboardResponse.RegistrationData() { Date = Data.GetDateTimeNow().Date.AddDays(1), Value = result.Advisors.LastOrDefault()?.Value ?? 0 }); result.UsersStartedRegistration.Add(new DashboardResponse.RegistrationData() { Date = Data.GetDateTimeNow().Date.AddDays(1), Value = result.UsersStartedRegistration.LastOrDefault()?.Value ?? 0 }); result.Following.Add(new DashboardResponse.DistributionData() { Name = "Asset", Amount = consideredAssetFollowers.Count() }); result.Following.Add(new DashboardResponse.DistributionData() { Name = "Expert", Amount = consideredAdvisorFollowers.Count() }); var usersWithReferral = consideredUsers.Where(c => c.ReferralStatus.HasValue); result.ReferralStatus = !usersWithReferral.Any() ? new List <DashboardResponse.DistributionData>() : usersWithReferral.GroupBy(c => c.ReferralStatus.Value) .Select(g => new DashboardResponse.DistributionData() { Name = ReferralStatusType.Get(g.Key).GetDescription(), Amount = g.Count() }).ToList(); var groupedFollowers = !consideredAdvisorFollowers.Any() ? null : consideredAdvisorFollowers.GroupBy(c => c.AdvisorId).Select(g => new { Id = g.Key, Value = g.Count() }).OrderByDescending(c => c.Value); if (groupedFollowers?.Any() == true) { groupedFollowers = groupedFollowers.Take(groupedFollowers.Count() > 10 ? 10 : groupedFollowers.Count()).OrderByDescending(c => c.Value); var consideredFollowers = consideredAdvisorFollowers.Where(c => groupedFollowers.Any(a => a.Id == c.AdvisorId)); result.AdvisorFollowers = groupedFollowers.Select(c => new DashboardResponse.AdvisorData() { Id = c.Id, Name = consideredAdvisors.First(a => a.Id == c.Id).Name, UrlGuid = consideredAdvisors.First(a => a.Id == c.Id).UrlGuid.ToString(), Total = c.Value, SubValue1 = consideredFollowers.Count(a => a.CreationDate >= cutDayForActivity && a.AdvisorId == c.Id) }).ToList(); } var groupedReferred = !usersWithReferral.Any() ? null : usersWithReferral.GroupBy(c => c.ReferredId.Value).Select(g => new { Id = g.Key, Value = g.Count() }).OrderByDescending(c => c.Value); if (groupedReferred?.Any() == true) { groupedReferred = groupedReferred.Take(groupedReferred.Count() > 10 ? 10 : groupedReferred.Count()).OrderByDescending(c => c.Value); var consideredReferred = consideredUsers.Where(c => c.ReferralStatus.HasValue).Where(c => groupedReferred.Any(a => a.Id == c.ReferredId)); result.AdvisorReferral = groupedReferred.Select(c => new DashboardResponse.AdvisorData() { Id = c.Id, Name = consideredAdvisors.Any(a => a.Id == c.Id) ? consideredAdvisors.First(a => a.Id == c.Id).Name : consideredUsers.Any(u => u.Id == c.Id) ? consideredUsers.First(u => u.Id == c.Id).Email : "(ADMIN) " + users.Result.First(u => u.Id == c.Id).Email, UrlGuid = consideredAdvisors.Any(a => a.Id == c.Id) ? consideredAdvisors.First(a => a.Id == c.Id).UrlGuid.ToString() : null, Total = c.Value, SubValue1 = consideredReferred.Count(a => a.ReferredId == c.Id && a.ReferralStatusType == ReferralStatusType.InProgress), SubValue2 = consideredReferred.Count(a => a.ReferredId == c.Id && a.ReferralStatusType == ReferralStatusType.Interrupted), SubValue3 = consideredReferred.Count(a => a.ReferredId == c.Id && (a.ReferralStatusType == ReferralStatusType.Finished || a.ReferralStatusType == ReferralStatusType.Paid)) }).ToList(); } return(result); }
protected virtual async Task WriteResponse(DashboardResponse response) { await WriteResource(response, _assembly, _resourceName); }
public async Task GetDashboard() { Random random = new Random(); Guid grantParentScopeId = random.NextGuid(); Guid parentScopeId = random.NextGuid(); Guid childScopeId = random.NextGuid(); DHCPv6RootScope rootScope = GetDHCPv6RootScope(); rootScope.Load(new List <DomainEvent> { new DHCPv6ScopeEvents.DHCPv6ScopeAddedEvent( new DHCPv6ScopeCreateInstruction { Name = "grant parent", Id = grantParentScopeId, }), new DHCPv6ScopeEvents.DHCPv6ScopeAddedEvent( new DHCPv6ScopeCreateInstruction { Name = "parent", Id = parentScopeId, ParentId = grantParentScopeId }), new DHCPv6ScopeEvents.DHCPv6ScopeAddedEvent( new DHCPv6ScopeCreateInstruction { Name = "child", Id = childScopeId, ParentId = parentScopeId }), }); DHCPv4RootScope dhcpv4RootScope = GetDHCPv4RootScope(); dhcpv4RootScope.Load(new List <DomainEvent> { new DHCPv4ScopeEvents.DHCPv4ScopeAddedEvent( new DHCPv4ScopeCreateInstruction { Name = "grant parent", Id = grantParentScopeId, }), new DHCPv4ScopeEvents.DHCPv4ScopeAddedEvent( new DHCPv4ScopeCreateInstruction { Name = "parent", Id = parentScopeId, ParentId = grantParentScopeId }), new DHCPv4ScopeEvents.DHCPv4ScopeAddedEvent( new DHCPv4ScopeCreateInstruction { Name = "child", Id = childScopeId, ParentId = parentScopeId }), }); DashboardResponse response = new DashboardResponse { DHCPv6 = new DHCPOverview <DHCPv6LeaseEntry, DHCPv6PacketHandledEntry> { ActiveInterfaces = random.Next(3, 10), }, DHCPv4 = new DHCPOverview <DHCPv4LeaseEntry, DHCPv4PacketHandledEntry> { ActiveInterfaces = random.Next(3, 10), }, }; Int32 expectedPipelineAmount = random.Next(3, 10); Mock <IDHCPv6ReadStore> readStoreMock = new Mock <IDHCPv6ReadStore>(MockBehavior.Strict); readStoreMock.Setup(x => x.GetDashboardOverview()).ReturnsAsync(response).Verifiable(); Mock <INotificationEngine> notificationEngineMock = new Mock <INotificationEngine>(MockBehavior.Strict); notificationEngineMock.Setup(x => x.GetPipelineAmount()).Returns(expectedPipelineAmount).Verifiable(); var controller = new DashboardController(rootScope, dhcpv4RootScope, readStoreMock.Object, notificationEngineMock.Object); var actionResult = await controller.GetDashboard(); var result = actionResult.EnsureOkObjectResult <DashboardResponse>(true); Assert.NotNull(result); Assert.NotNull(result.DHCPv6); Assert.NotNull(result.DHCPv4); Assert.Equal(3, result.DHCPv6.ScopeAmount); Assert.Equal(response.DHCPv6.ActiveInterfaces, result.DHCPv6.ActiveInterfaces); Assert.Equal(expectedPipelineAmount, result.AmountOfPipelines); Assert.Equal(3, result.DHCPv4.ScopeAmount); Assert.Equal(response.DHCPv4.ActiveInterfaces, result.DHCPv4.ActiveInterfaces); readStoreMock.Verify(); }
protected virtual void WriteResponse(DashboardResponse response) { WriteResource(response, _assembly, _resourceName); }