Implemented GetAll and wireing up

This commit is contained in:
2020-03-26 22:28:40 +01:00
parent 1a686aba60
commit 9d80089a23
6 changed files with 97 additions and 17 deletions

View File

@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using TrackerLibrary.Models;
@ -16,9 +17,10 @@ namespace TrackerLibrary.DataAccess
{
public class SqlConnector : IDataConnection
{
private const string db = "Tournaments";
public PersonModel CreatePerson(PersonModel model)
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("Tournaments"))) {
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db))) {
var p = new DynamicParameters();
p.Add("@FirstName", model.FirstName);
p.Add("@LastName", model.LastName);
@ -42,7 +44,7 @@ namespace TrackerLibrary.DataAccess
/// <returns>The prize information, including the unique identifier.</returns>
public Models.PrizeModel CreatePrize(Models.PrizeModel model)
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("Tournaments")))
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
{
var p = new DynamicParameters();
p.Add("@PlaceNumber", model.PlaceNumber);
@ -58,5 +60,16 @@ namespace TrackerLibrary.DataAccess
return model;
}
}
public List<PersonModel> GetPerson_All()
{
List<PersonModel> output;
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
{
output = connection.Query<PersonModel>("dbo.spPeople_GetAll").ToList();
}
return output;
}
}
}