Create team form is ready (nearly)
This commit is contained in:
@ -20,7 +20,8 @@ namespace TrackerLibrary.DataAccess
|
||||
private const string db = "Tournaments";
|
||||
public PersonModel CreatePerson(PersonModel model)
|
||||
{
|
||||
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db))) {
|
||||
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);
|
||||
@ -61,6 +62,33 @@ namespace TrackerLibrary.DataAccess
|
||||
}
|
||||
}
|
||||
|
||||
public TeamModel CreateTeam(TeamModel model)
|
||||
{
|
||||
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
|
||||
{
|
||||
var p = new DynamicParameters();
|
||||
p.Add("@TeamName", model.TeamName);
|
||||
p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
|
||||
|
||||
connection.Execute("dbo.spTeams_Insert", p, commandType: CommandType.StoredProcedure);
|
||||
|
||||
model.Id = p.Get<int>("@Id");
|
||||
|
||||
foreach(PersonModel tm in model.TeamMembers)
|
||||
{
|
||||
p = new DynamicParameters();
|
||||
p.Add("@TeamId", model.Id);
|
||||
p.Add("@PersonId", tm.Id);
|
||||
|
||||
connection.Execute("dbo.spTeamMembers_Insert", p, commandType: CommandType.StoredProcedure);
|
||||
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<PersonModel> GetPerson_All()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user