public int UpdatePerson(Person updatedPerson) { if (PersonList.ContainsKey(updatedPerson.UserId)) { PersonList[updatedPerson.UserId] = updatedPerson; } else { throw new ArgumentException("Person has a user id but does not exist in data store"); } return updatedPerson.UserId; }
public int SavePerson(Person addedPerson) { if (addedPerson.UserId != 0) { return UpdatePerson(addedPerson); } var newUserId = PersonList.Count + 1; addedPerson.UserId = newUserId; PersonList.Add(addedPerson.UserId, addedPerson); return addedPerson.UserId; }
public int SavePerson(int id, Person savedPerson) { PersonList.Add(id, savedPerson); return id; }