Last active
March 7, 2019 12:29
-
-
Save jonhilt/afe6c362c9fea4cc542cd133b58dab22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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