public static void AddDummyContacts(this IContactStore source, int number) { foreach (var index in Enumerable.Range(1, number)) { source.Add(new dummyContact(index)); } }
/// <summary> /// Add a contact to the database. /// </summary> /// <remarks>Do not alter once handed off</remarks> /// <param name="contactToAdd">The contact to add. Don't modify once handed off.</param> /// <param name="preferedStorage">Where to store it. If null, stored in default spot</param> public void Add(IContact contactToAdd, IContactStore preferedStorage = null) { if (preferedStorage == null) { _preferedStore.Add(contactToAdd); } else { preferedStorage.Add(contactToAdd); } }
private async Task Save() { if (String.IsNullOrWhiteSpace(Contact.FirstName) && String.IsNullOrWhiteSpace(Contact.LastName)) { await _pageService.DisplayAlert("Error", "Please enter the name.", "OK"); return; } if (Contact.Id == 0) { await _contactStore.Add(Contact); ContactAdded?.Invoke(this, Contact); } else { await _contactStore.Update(Contact); ContactUpdated?.Invoke(this, Contact); } await _pageService.PopAsync(); }