Пример #1
0
        public async Task <List <CourseDto> > GetCourses(NoInput input)
        {
            List <CourseDto> coursesDto = new List <CourseDto>();
            var courses = await _context.Courses.ToListAsync();

            if (courses != null)
            {
                coursesDto = Mapper.Map <List <CourseDto> >(courses);
            }

            return(coursesDto);
        }
Пример #2
0
        public async Task <List <StudentDto> > GetStudents(NoInput input)
        {
            List <StudentDto> studentsDto = new List <StudentDto>();
            var students = await _context.Students.ToListAsync();

            if (students != null)
            {
                studentsDto = Mapper.Map <List <StudentDto> >(students);
            }

            return(studentsDto);
        }
        public override Task <QueryResult <List <KnownEndpointsView> > > LocalQuery(Request request, NoInput input)
        {
            var result = EndpointInstanceMonitoring.GetKnownEndpoints();

            return(Task.FromResult(new QueryResult <List <KnownEndpointsView> >(result, new QueryStatsInfo(string.Empty, result.Count))));
        }
Пример #4
0
        public override async Task <QueryResult <IList <KnownEndpointsView> > > Query(Request request, NoInput input)
        {
            using (var session = Store.OpenAsyncSession())
            {
                var endpoints = await session.Query <EndpointDetails, EndpointsIndex>()
                                .Statistics(out var stats)
                                .ToListAsync()
                                .ConfigureAwait(false);

                var knownEndpoints = endpoints
                                     .Select(x => new KnownEndpointsView
                {
                    Id = DeterministicGuid.MakeId(x.Name, x.HostId.ToString()),
                    EndpointDetails = x,
                    HostDisplayName = x.Host
                })
                                     .ToList();

                return(new QueryResult <IList <KnownEndpointsView> >(knownEndpoints, stats.ToQueryStatsInfo()));
            }
        }