Changed to newer framework in tracker project

This commit is contained in:
2020-03-23 00:39:45 +01:00
parent 88bd9b894a
commit bf67841d48
8 changed files with 139 additions and 10 deletions

View File

@ -1,7 +1,16 @@
using System;
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
//@PlaceNumber int,
//@PlaceName nvarchar(50),
//@PrizeAmount money,
// @PrizePercentage float,
//@id int = 0 output
namespace TrackerLibrary.DataAccess
{
public class SqlConnector : IDataConnection
@ -14,8 +23,21 @@ namespace TrackerLibrary.DataAccess
/// <returns>The prize information, including the unique identifier.</returns>
public Models.PrizeModel CreatePrize(Models.PrizeModel model)
{
model.Id = 1;
return model;
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("Tournaments")))
{
var p = new DynamicParameters();
p.Add("@PlaceNumber", model.PlaceNumber);
p.Add("@PlaceName", model.PlaceName);
p.Add("@PrizeAmount", model.PrizeAmount);
p.Add("@PrizePercentage", model.PrizePercentage);
p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
connection.Execute("dbo.spPrizes_Insert", p, commandType: CommandType.StoredProcedure);
model.Id = p.Get<int>("@Id");
return model;
}
}
}
}