コード例 #1
0
ファイル: Manager.cs プロジェクト: amandamc4/bti420winter2015
        // 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;
        }
コード例 #2
0
        // 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);
        }