public AssetStatusesViewModel() { AssetStatuses = DatabaseQueries.GetStatuses(); AssetStatuses.ItemPropertyChanged += AssetStatuses_ItemPropertyChanged; //populate from database AssetLabel = selectedassetlabel; if (AssetStatuses.Count > 0) { AssetLabel = selectedassetlabel; } else { AssetLabel = newassetlabel; } _assetstatus = new Models.StatusModel(); _isediting = true; _scrolltolastitem = false; ScrollToSelectedItem = 0; CloseBtnLabel = _closelabel; }
private void ExecuteSaveAndClose(object parameter) { if (!AssetStatusesListEnabled) { Models.StatusModel _newassetstatus = new Models.StatusModel(); _newassetstatus.Status = AssetStatus.Status ?? string.Empty; DatabaseQueries.AddStatus(_newassetstatus); AssetStatuses = DatabaseQueries.GetStatuses(); AssetStatuses.ItemPropertyChanged += AssetStatuses_ItemPropertyChanged; } else { foreach (Models.StatusModel sm in AssetStatuses) { DatabaseQueries.UpdateStatus(sm); } } _canexecuteadd = true; // _isediting = true; AssetStatusesListEnabled = true; AssetLabel = selectedassetlabel; CloseBtnLabel = _closelabel; }