/// <summary> /// Creates a new Section with default values /// </summary> /// <returns></returns> internal TeamMember Create() { TeamMember teamMember = new TeamMember { FacebookLink = "http://www.facebook.com" }; return teamMember; }
/// <summary> /// Saves a new Section. /// </summary> /// <param name="Section"></param> /// <returns></returns> internal TeamMember Save(TeamMember teamMember) { // Read in the existing Sections var teamMembers = this.Retrieve(); // Assign a new Id var maxId = teamMembers.Max(p => p.TeamMemberId); teamMember.TeamMemberId = maxId + 1; teamMembers.Add(teamMember); WriteData(teamMembers); return teamMember; }
/// <summary> /// Updates an existing Section /// </summary> /// <param name="id"></param> /// <param name="Section"></param> /// <returns></returns> internal TeamMember Save(int id, TeamMember teamMember) { // Read in the existing Sections var teamMembers = this.Retrieve(); // Locate and replace the item var itemIndex = teamMembers.FindIndex(p => p.TeamMemberId == teamMember.TeamMemberId); if (itemIndex > 0) { teamMembers[itemIndex] = teamMember; } else { return null; } WriteData(teamMembers); return teamMember; }