Personmodel handled as dbtabel and as file

This commit is contained in:
2020-03-26 20:49:46 +01:00
parent 27f406b836
commit 1a686aba60
8 changed files with 135 additions and 10 deletions

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using TrackerLibrary.Models;
//@PlaceNumber int,
@ -15,6 +16,24 @@ namespace TrackerLibrary.DataAccess
{
public class SqlConnector : IDataConnection
{
public PersonModel CreatePerson(PersonModel model)
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("Tournaments"))) {
var p = new DynamicParameters();
p.Add("@FirstName", model.FirstName);
p.Add("@LastName", model.LastName);
p.Add("@EmailAddress", model.EmailAddress);
p.Add("@CellPhoneNumber", model.CellPhoneNumber);
p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
connection.Execute("dbo.spPeople_Insert", p, commandType: CommandType.StoredProcedure);
model.Id = p.Get<int>("@Id");
return model;
}
}
// TODO - Make the CreatePrize method actually save to the database
/// <summary>
/// Saves a prize to the database