public async Task ExecuteAsync(IQueryResponse <List <DeveloperDto> > queryResponse)
        {
            await _auditService.LogAccess(nameof(GetAllDevelopersQuery));

            var developers = await _dbContext
                             .GetAllQuery <Developer>()
                             .Include(d => d.PrimaryLanguage)
                             .ToListAsync();

            var response = developers
                           .Select(d =>
                                   new DeveloperDto()
            {
                DeveloperId       = d.DeveloperId,
                FirstName         = d.FirstName,
                LastName          = d.LastName,
                Gender            = Enum.GetName(typeof(Gender), d.Gender),
                Level             = Enum.GetName(typeof(AbilitonLevel), d.Level),
                PrimaryLanguage   = d.PrimaryLanguage.Name,
                YearsOfExperience = d.YearsOfExperience
            })
                           .ToList();

            queryResponse.Respond(response);
        }
Esempio n. 2
0
        public async Task ExecuteAsync(IQueryResponse <List <GenderAverageDto> > queryResponse)
        {
            await _auditService.LogAccess(nameof(GetAverageByGenderQuery));

            using (var connection = new SqlConnection(_connectionStringProvider.GetConnectionString()))
            {
                var result = await connection.QueryAsync <GenderAverageDto>(
                    @"SELECT D.Gender, AVG(A.YearSalary) AS Value 
                        FROM SurveyAnswer A
	                        INNER JOIN Developer D ON D.DeveloperId = A.DeveloperId
                        GROUP BY D.Gender
                        ORDER BY Value DESC");

                queryResponse.Respond(result.ToList());
            }
        }
        public async Task ExecuteAsync(IQueryResponse <List <ProgrammingLanguageDto> > queryResponse)
        {
            await _auditService.LogAccess(nameof(GetMostUsedProgrammingLanguages));

            var response = await _dbContext
                           .GetAllNoCachingQuery <ProgrammingLanguage>()
                           .Select(l =>
                                   new ProgrammingLanguageDto()
            {
                ProgrammingLanguageId = l.ProgrammingLanguageId,
                Name            = l.Name,
                IsStronglyTyped = l.IsStronglyTyped
            })
                           .ToListAsync();

            queryResponse.Respond(response);
        }