public void UpdateStateParametersTest() { var target = new object(); bool isInvoked = false; var oldState = EntityState.Unchanged; var newState = EntityState.Unchanged; _transitionManager.ChangeState = (item, state, entityState) => { isInvoked = true; state.ShouldEqual(oldState); entityState.ShouldEqual(newState); target.ShouldEqual(item); return(entityState); }; ITrackingCollection collection = Create(_transitionManager); oldState = EntityState.Detached; newState = EntityState.Added; collection.UpdateState(target, newState); isInvoked.ShouldBeTrue(); isInvoked = false; oldState = EntityState.Added; newState = EntityState.Modified; collection.UpdateState(target, newState); }
private async Task RemoveOrder(OrderModel obj) { OrderModel item = obj ?? GridViewModel.SelectedItem; string message = string.Format(UiResources.DeleteOrderQuestionFormat, item.Name); if (await _messagePresenter.ShowAsync(message, DisplayName, MessageButton.YesNo, MessageImage.Question) != MessageResult.Yes) { return; } var productModels = await GetOrLoadProductLinks(item); _trackingCollection.UpdateState(item, EntityState.Deleted); _trackingCollection.UpdateStates(productModels, EntityState.Deleted); GridViewModel.OriginalItemsSource.Remove(item); this.OnPropertyChanged(() => v => v.HasChanges); }
private async void RemoveProduct(ProductModel obj) { ProductModel item = obj ?? GridViewModel.SelectedItem; string message = string.Format(UiResources.DeleteProductQuestionFormat, item.Name); if (await _messagePresenter.ShowAsync(message, DisplayName, MessageButton.YesNo, MessageImage.Question) != MessageResult.Yes) { return; } _trackingCollection.UpdateState(item, EntityState.Deleted); GridViewModel.OriginalItemsSource.Remove(item); OnPropertyChanged(() => HasChanges); }