public async Task <IEnumerable <ViewModel.CategoryReadModel> > GetCategoriesAsync() { using (var db = new SqlConnection(_connectionStringFactory.ToDatabase())) { var sql = "SELECT [Id], [Name] FROM [Interview].[Category]"; return(await db.QueryAsync <ViewModel.CategoryReadModel>(sql)); } }
public async Task <IEnumerable <int> > GetQuestionIdsThatHasAnswerAsync() { using (var db = new SqlConnection(_connectionStringFactory.ToDatabase())) { var sql = $"SELECT Id FROM [Interview].[Question] WHERE [Answer] IS NOT NULL"; return(await db.QueryAsync <int>(sql)); } }
public async Task <IEnumerable <vw_QuestionDetails> > GetQuestionsAsync() { using (var db = new SqlConnection(_connectionStringFactory.ToDatabase())) { var sql = "SELECT * FROM [Interview].[vw_QuestionDetails]"; return(await db.QueryAsync <vw_QuestionDetails>(sql)); } }
public async Task <int> Handle(Query query, CancellationToken cancellationToken) { using (var db = new SqlConnection(_connectionStringFactory.ToDatabase())) { var sql = $"SELECT UserId FROM [vw_UserDetails]"; return(await db.QueryFirstAsync <int>(sql)); } }
public async Task <ViewModel.CategoryInputModel> GetCategoryAsync(int id) { using (var db = new SqlConnection(_connectionStringFactory.ToDatabase())) { var sql = $"SELECT [Id], [Name] FROM [Interview].[Category] WHERE [Id] = { id }"; return(await db.QueryFirstAsync <ViewModel.CategoryInputModel>(sql)); } }