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

@ -9,5 +9,6 @@ namespace TrackerLibrary.DataAccess
{
PrizeModel CreatePrize(PrizeModel model);
PersonModel CreatePerson(PersonModel model);
List<PersonModel> GetPerson_All();
}
}

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;
}
}
}

View File

@ -58,5 +58,10 @@ namespace TrackerLibrary.DataAccess
return model;
}
public List<PersonModel> GetPerson_All()
{
return PeopleFile.FullFilePath().LoadFile().ConvertToPersonModels();
}
}
}

View File

@ -14,5 +14,10 @@ namespace TrackerLibrary.Models
public string LastName { get; set; }
public string EmailAddress { get; set; }
public string CellPhoneNumber { get; set; }
public string FullName
{
get { return $"{FirstName} {LastName}"; }
}
}
}