public NewItemPage(PhonesBook item) { InitializeComponent(); NewItemViewModel vm = new NewItemViewModel(item); BindingContext = vm; }
public async void RemovePhone(PhonesBook item) { if (!await _dataStore.DeleteItemAsync(item)) { return; } Collection.Remove(item); OnCollectionChanged(NotifyCollectionChangedAction.Remove, item); }
public async void AddPhone(PhonesBook item) { if (!await _dataStore.AddItemAsync(item)) { return; } Collection.Add(item); OnCollectionChanged(NotifyCollectionChangedAction.Add, item); }
public void DeleteAt(int index) { if (index >= 0) { PhonesBook.RemoveAt(index); } else { throw new Exception("No have this client in phone book "); } }
public async void EditPhone(PhonesBook item) { if (!await _dataStore.UpdateItemAsync(item)) { return; } PhonesBook element = Collection.Find(el => el.Id == item.Id); Collection.Remove(element); OnCollectionChanged(NotifyCollectionChangedAction.Remove, element); Collection.Add(item); OnCollectionChanged(NotifyCollectionChangedAction.Add, item); }
public NewItemViewModel(PhonesBook item) { _collection = PhonesCollection.GetPhonesCollection; Save = new Command(ExecuteSave); PhonesBook phone = new PhonesBook { Id = item.Id, Name = item.Name, Surname = item.Surname, Phone = item.Phone }; Item = phone; }
public void Delete(Client client) { PhonesBook.Remove(client); }
public void Add(Client client) { PhonesBook.Add(client); Count++; }
protected void OnCollectionChanged(NotifyCollectionChangedAction action, PhonesBook item) { CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(action, item)); }
public NewItemViewModel() { _collection = PhonesCollection.GetPhonesCollection; Save = new Command(ExecuteSave); Item = new PhonesBook(); }