Skip to content

Instantly share code, notes, and snippets.

@jonhilt
Last active March 7, 2019 12:29
Show Gist options
  • Save jonhilt/afe6c362c9fea4cc542cd133b58dab22 to your computer and use it in GitHub Desktop.
Save jonhilt/afe6c362c9fea4cc542cd133b58dab22 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Net.Mail;
using System.Threading.Tasks;
using Dapper;
using Donatello.Controllers.Api;
using Donatello.Infrastructure;
using Donatello.Models;
using Donatello.ViewModels;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace Donatello.Services
{
public class BoardService
{
private readonly DonatelloContext dbContext;
private readonly IConfiguration configuration;
public BoardService(DonatelloContext dbContext, IConfiguration configuration)
{
this.dbContext = dbContext;
this.emails = emails;
this.configuration = configuration;
}
public BoardList ListBoards()
{
var model = new BoardList();
using(var connection = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
{
var boards = connection.Query<Board>("select * from Boards");
foreach (var board in boards)
{
model.Boards.Add(new BoardList.Board
{
Id = board.Id,
Title = board.Title
});
}
}
return model;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment