コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }