Esempio n. 1
0
		public async Task UpdatePerson(Person person)
		{
			var foundPerson = _people.FirstOrDefault(p => p.Id == person.Id);
			if (foundPerson == null) throw new ArgumentException($"Could not find a person with Id {person.Id}");

			foundPerson.FirstName = person.FirstName;
			foundPerson.LastName = person.LastName;
			foundPerson.Birthday = person.Birthday;

			PersonChanged?.Invoke(this, null);

			await Task.FromResult(string.Empty);
		}
		public IndexedTableSource(Person[] people, UITableViewController owner)
		{
			this.owner = owner;

			indexedTableItems = new Dictionary<string, List<Person>>();
			foreach (var person in people)
			{
				if (indexedTableItems.ContainsKey(person.FullName[0].ToString()))
				{
					indexedTableItems[person.FullName[0].ToString()].Add(person);
				}
				else {
					indexedTableItems.Add(person.FullName[0].ToString(), new List<Person> { person });
				}
			}
			keys = indexedTableItems.Keys.ToArray();
		}
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.PersonDetail);
            Button.Click += StorePerson;
            FirstnameText.TextChanged += FirstnameTextOnTextChanged;
            LastnameText.TextChanged += LastnameTextOnTextChanged;

            var personId = Intent.GetIntExtra("PersonId", 0);
            if (personId > 0)
            {
                Person = await _addressBook.GetPerson(personId);
            }
            else
            {
                Person = new Person();
            }
        }
Esempio n. 4
0
		public async Task UpdatePerson(Person person)
		{
			await Init();

			var foundPerson = _people.FirstOrDefault(p => p.Id == person.Id) ?? new Person();

			if (foundPerson.Id == 0)
			{
				foundPerson.Id = (_people.Last().Id + 1);
				var people = new List<Person>(_people);
				people.Add(foundPerson);
				_people = people;
			}

			foundPerson.FirstName = person.FirstName;
			foundPerson.LastName = person.LastName;
			foundPerson.Birthday = person.Birthday;

			await StorePeopleToFile();

			PersonChanged?.Invoke(this, null);
		}
		internal void SetPerson(AddressBookOverviewTableViewController addressBookOverviewTableViewController, Person person)
		{
			if (person == null)
				throw new ArgumentNullException(nameof(person));
			Person = person;
			Firstname = person.FirstName;
			Lastname = person.LastName;
		}