// Add a new person public PersonFull AddPerson(PersonAdd newItem) { // Calculate the next value for the identifier int newId = (persons.Count > 0) ? newId = persons.Max(id => id.Id) + 1 : 1; // Create a new item; notice the property mapping var addedItem = new PersonFull { Id = newId, FirstName = newItem.FirstName, LastName = newItem.LastName, Age = newItem.Age }; // Add the new item to the store persons.Add(addedItem); // Return the new item return addedItem; }
// Add a new person public PersonFull AddPerson(PersonAdd newItem) { // Calculate the next value for the identifier int newId = (persons.Count > 0) ? newId = persons.Max(id => id.Id) + 1 : 1; // Create a new item; notice the property mapping var addedItem = new PersonFull { Id = newId, FirstName = newItem.FirstName, LastName = newItem.LastName, Age = newItem.Age }; // Add the new item to the store persons.Add(addedItem); // Return the new item return(addedItem); }