public async Task <CheckDetailDTO> EditAsync([FromBody] CheckDetailDTO value)
        {
            Check check;

            if (value.ID > 0)
            {
                check = await _checks.GetDetails(value.ID);
            }
            else
            {
                check = new Check
                {
                    Schedules = new List <CheckSchedule>()
                };
                _checks.Add(check);
            }

            _mapper.Map(value, check);

            await _checks.SaveChangesAsync();

            await _manager.UpdateSchedule(check);

            return(await GetDetailsAsync(check.ID));
        }
Exemplo n.º 2
0
        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);
                }
            }
        }
Exemplo n.º 3
0
        public void Add(Check check)
        {
            Check alReadyExistingCheck = _checkRepository.GetCheckByNumber(check.CheckNumber);

            if (alReadyExistingCheck != null
                & alReadyExistingCheck.Bank.Id == check.Id)
            {
                throw new Exception("Check with this Number already exists");
            }

            _checkRepository.Add(check);
        }