private void OnSave() { try { switch (_currentOperation) { case Operation.AddNewAccount: var account = new Account(AccountNumber, Bank, Branch, Amount, IfscCode, (AccountTypeEnum)Enum.Parse(typeof(AccountTypeEnum), AccountType)); Dal.AddAccount(account); break; case Operation.UpdateAccountDetails: var updateAccount = new Account(AccountNumber, Bank, Branch, Amount, IfscCode, (AccountTypeEnum)Enum.Parse(typeof(AccountTypeEnum), AccountType)); Dal.Update(updateAccount); break; case Operation.DeleteAccount: Dal.Delete(SelectedAccount); break; case Operation.None: break; default: throw new ArgumentOutOfRangeException(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Assets", MessageBoxButton.OK, MessageBoxImage.Error); } finally { _currentOperation = Operation.None; IsAccountDetailsEnabled = false; } }