private void SaveButton_OnClick(object sender, RoutedEventArgs e) { _isValidInputs = true; ValidateInputs(); Check check = MakeCheck(); if (_isValidInputs) { if (_model.Operation == Operation.Add) { check.CreatedDate = DateTime.Now; _checkRepository.Add(check); } else if (_model.Operation == Operation.Edit) { check.ModifiedDate = DateTime.Now; check.Id = _model.CheckToEdit; _checkRepository.Update(check); } if (_checkRepository.IsSuccess) { IsCanceled = false; Close(); } else { MessageBox.Show(_checkRepository.ErrorMessage); } } }
public void Update(Check check) { Check oldCheck = _checkRepository.GetCheckByNumber(check.CheckNumber); oldCheck.CheckNumber = check.CheckNumber; oldCheck.Bank = check.Bank; oldCheck.DateIssued = check.DateIssued; oldCheck.Amount = check.Amount; oldCheck.IssuedTo = check.IssuedTo; oldCheck.ModifiedDate = DateTime.Now; _checkRepository.Update(oldCheck); }
private void SaveButton_OnClick(object sender, RoutedEventArgs e) { DateTime?onHoldDate = GetOnHoldDate(); bool isFunded = IsFunded.IsChecked.HasValue && IsFunded.IsChecked.Value; bool isSettled = IsSettled.IsChecked.HasValue && IsSettled.IsChecked.Value; _check.HoldDate = onHoldDate; _check.IsFunded = isFunded; _check.IsSettled = isSettled; _check.Notes = NotesText.Text; _checkRepository.Update(_check); IsCancelled = false; Close(); }