Implemented GetAll and wireing up
This commit is contained in:
@ -9,5 +9,6 @@ namespace TrackerLibrary.DataAccess
|
||||
{
|
||||
PrizeModel CreatePrize(PrizeModel model);
|
||||
PersonModel CreatePerson(PersonModel model);
|
||||
List<PersonModel> GetPerson_All();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,5 +58,10 @@ namespace TrackerLibrary.DataAccess
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public List<PersonModel> GetPerson_All()
|
||||
{
|
||||
return PeopleFile.FullFilePath().LoadFile().ConvertToPersonModels();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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}"; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user