public bool CreateTeam(string name, decimal price, string description, DateTime startPeriod, DateTime endPeriod, int maxNumberOfParticipants, string trainingSchedule) { try { ITeam team = new Team(name, price, description, startPeriod, endPeriod, maxNumberOfParticipants, trainingSchedule, true); team = TeamPersistence.CreateTeam(team); if (team != null) { teamList.Insert(0, team); return true; } } catch (Exception) { return false; } return false; }
public bool UpdateTeam(string name, decimal price, string description, DateTime startPeriod, DateTime endPeriod, int maxNumberOfParticipants, string trainingSchedule, int activityId, bool activated) { try { ITeam thisTeam = new Team(name, price, description, startPeriod, endPeriod, maxNumberOfParticipants, trainingSchedule, activated, activityId); if (TeamPersistence.UpdateTeam(thisTeam)) { ITeam teamInList = RetrieveSingleTeam(thisTeam.ActivityId); updateTeamProperties(teamInList, thisTeam); return true; } return false; } catch (Exception) { return false; } }
public static List<ITeam> RetrieveTeams() { List<ITeam> teamList = new List<ITeam>(); if (Connect()) { SqlCommand Command = Connection.CreateCommand(); Command.CommandType = CommandType.StoredProcedure; Command.CommandText = "fif_team_retrieve"; SqlDataReader dataReader = Command.ExecuteReader(); while (dataReader.Read()) { int id = int.Parse(dataReader["activity_id"].ToString()); string name = dataReader["name"].ToString(); decimal price = decimal.Parse(dataReader["price"].ToString()); string desciption = dataReader["description"].ToString(); DateTime startPeriod = DateTime.Parse(dataReader["start_period"].ToString()); DateTime endPeriod = DateTime.Parse(dataReader["end_period"].ToString()); int maxNumberOfParticipants = int.Parse(dataReader["max_number_of_participants"].ToString()); string trainingSchedule = dataReader["schedule"].ToString(); ITeam team = new Team(id, name, price, desciption, startPeriod, endPeriod, maxNumberOfParticipants, trainingSchedule); teamList.Add(team); } Disconnect(); return teamList; } return null; }