public List <Person> GetPerson_All() { List <Person> output; using (IDbConnection connection = new SqlConnection(GlobalConfiguration.CnnValue(Value))) { output = connection.Query <Person>("dbo.spPerson_GetAll").ToList(); } return(output); }
public void CreateTournament(Tournaments t) { using (IDbConnection connection = new SqlConnection(GlobalConfiguration.CnnValue(Value))) { SaveTournament(connection, t); SaveTournamnetPrizes(connection, t); SaveEnteredTeams(connection, t); } }
public Person CreatePerson(Person person) { using (IDbConnection connect = new SqlConnection(GlobalConfiguration.CnnValue(Value))) { var p = new DynamicParameters(); p.Add("@firstName", person.FirstName); p.Add("@lastName", person.LastName); p.Add("@emailAddress", person.EmailAddress); p.Add("@cellPhoneNumber", person.CellPhoneNumber); p.Add("@id", 0, DbType.Int32, ParameterDirection.Output); connect.Execute("dbo.spPeople_Insert", p, commandType: CommandType.StoredProcedure); person.Id = p.Get <int>("@id"); return(person); } }
//TODO- Vytvorit metodu CreatePrize a ulozit do database /// <summary> /// ulozi novou cenu do database /// </summary> /// <param name="model">Informace o cene </param> /// <returns>Informace o cene plus unikatni identifikaci</returns> public Prize CreatePrize(Prize model) { using (IDbConnection connection = new SqlConnection(GlobalConfiguration.CnnValue(Value))) { var p = new DynamicParameters(); p.Add("@PlaceNumber", model.PlaceNumber); p.Add("@PlaceName", model.PlaceName); p.Add("@PrizeAmount", model.PrizeAmount); p.Add("@PrizePersentage", 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); } }
public List <Team> GetTeam_All() { List <Team> output; using (IDbConnection connect = new SqlConnection(GlobalConfiguration.CnnValue(Value))) { output = connect.Query <Team>("dbo.spTeam_GetAll").ToList(); foreach (var team in output) { var p = new DynamicParameters(); p.Add("@teamId", team.Id); p.Add("@teamName", team.TeamName); team.TeamMembers = connect.Query <Person>("dbo.spTeamMembers_GetByTeam").ToList(); } } return(output); }
public Team CreateTeam(Team team) { using (IDbConnection connection = new SqlConnection(GlobalConfiguration.CnnValue(Value))) { var p = new DynamicParameters(); p.Add("@PlaceNumber", team.TeamName); p.Add("@id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output); connection.Execute("dbo.spTeams_Insert_Insert", p, commandType: CommandType.StoredProcedure); team.Id = p.Get <int>("@id"); foreach (var tm in team.TeamMembers) { p = new DynamicParameters(); p.Add("@teamId", team.Id); p.Add("@teamMemberId", tm.Id); connection.Execute("dbo.spTeamMembers_Insert", p, commandType: CommandType.StoredProcedure); } return(team); } }