예제 #1
0
        public Task <CommandResult> Handle(AddChequeCommand command, CancellationToken cancellationToken)
        {
            if (!command.IsValid())
            {
                NotifyCommandErrors(command);
                return(Response());
            }

            if (_chequeRepository.CheckNumeroChequeExists(command.NumeroCheque, command.ClienteId, command.BancoId, command.Id))
            {
                NotifyCommandError(RequestErrorsMessageConstants.ChequeAlreadyExists);
                return(Response());
            }

            Banco   banco   = _bancoRepository.GetById(command.BancoId, loadRelatedData: false);
            Cliente cliente = _clienteRepository.GetById(command.ClienteId, loadRelatedData: false);
            Cheque  cheque  = new Cheque(banco, command.Agencia, command.Conta, command.NumeroCheque, cliente, command.DataEmissao, command.DataVencimento, command.Valor);

            _chequeRepository.Add(cheque);

            if (Commit())
            {
                _mediator.Publish(new AddedChequeEvent());
            }

            return(Response());
        }
예제 #2
0
 public Int32 Edit(BANCO item, LOG log)
 {
     using (DbContextTransaction transaction = Db.Database.BeginTransaction(IsolationLevel.ReadCommitted))
     {
         try
         {
             BANCO obj = _baseRepository.GetById(item.BANC_CD_ID);
             _baseRepository.Detach(obj);
             _logRepository.Add(log);
             _baseRepository.Update(item);
             transaction.Commit();
             return(0);
         }
         catch (Exception ex)
         {
             transaction.Rollback();
             throw ex;
         }
     }
 }
        public BaseRetornoDTO <BancoViewModel> GetById(int id)
        {
            BaseRetornoDTO <BancoViewModel> retornoDTO = new BaseRetornoDTO <BancoViewModel>();

            BaseExceptionSystem <BancoViewModel> .BaseHandleExcetion(() =>
            {
                var banco = _bancoRepository.GetById(id);

                retornoDTO.Value = Mapper.Map <BancoEntity, BancoViewModel>(banco);
            }, MensagemSistema.FormataMensagem(MensagemSistema.NenhumResultadoEncontrado, MensagemSistema.Banco), ref retornoDTO);

            return(retornoDTO);
        }
예제 #4
0
        public Task <CommandResult> Handle(RemoveBancoCommand command, CancellationToken cancellationToken)
        {
            if (!command.IsValid())
            {
                NotifyCommandErrors(command);
                return(Response());
            }

            Banco banco = _bancoRepository.GetById(command.Id);

            _bancoRepository.Remove(banco);

            if (Commit())
            {
                _mediator.Publish(new RemovedBancoEvent());
            }

            return(Response());
        }