public President Post([FromBody] President president) { List <President> presidents = _flatFileMechanics.GetPresidents(); ValidationRulesUtility.ValidateName(presidents, president.Name); ValidationRulesUtility.ValidateParty(president.Party); presidents.Add(president); _flatFileMechanics.SetPresidents(presidents); return(president); }
public void Put(string id, [FromBody] President president) { List <President> presidents = _flatFileMechanics.GetPresidents(); ValidationRulesUtility.ValidateName(presidents, president.Name, id); ValidationRulesUtility.ValidateParty(president.Party); presidents.ForEach(p => { if (id == p.Name) { p.Name = president.Name; p.Party = president.Party; p.HasNonconsecutiveTerms = president.HasNonconsecutiveTerms; } }); _flatFileMechanics.SetPresidents(presidents); }