public void Edit(ContactModel contactModel) { _connection.Table<ContactModel>().Delete(model => model.Id == contactModel.Id); Add(contactModel); }
private async void SaveNewContact() { isValidData = true; ErrorLabel = ""; if (FirstName.Trim() == "") { ErrorLabel += "\nFirst Name is required"; isValidData = false; } if (SecondName.Trim() == "") { ErrorLabel += "\nSecond Name is required"; isValidData = false; } if (PhoneNumber.Trim() == "") { ErrorLabel += "\nPhone Number is required"; isValidData = false; } if (isValidData) { var cm = new ContactModel { Id = Id, FirstName = FirstName, SecondName = SecondName, PhoneNumber = PhoneNumber, AdditionalPhoneNumber = AdditionalPhoneNumber, City = City }; if (Id == 0) { _contactService.Add(cm); } else { _contactService.Edit(cm); } await _navigation.PopAsync(); } }
public void Add(ContactModel contactModel) { _connection.Insert(contactModel); }