public long Add(NotaFiscalAddCommand notaFiscal)
        {
            var notaFiscalAdd = Mapper.Map <NotaFiscalAddCommand, NotaFiscal>(notaFiscal);

            notaFiscalAdd.Destinatario  = _destinatarioRepository.GetById(notaFiscal.DestinatarioId);
            notaFiscalAdd.Transportador = _transportadorRepository.GetById(notaFiscal.TransportadorId);
            notaFiscalAdd.Emitente      = _emitenteRepository.GetById(notaFiscal.EmitenteId);
            notaFiscalAdd.DataEmissao   = notaFiscalAdd.DataEntrada;

            return(_notaFiscalRepository.Add(notaFiscalAdd).Id);
        }
Example #2
0
        public bool Update(EmitenteUpdateCommand emitente)
        {
            var _emitente = _repository.GetById(emitente.Id);

            if (_emitente == null)
            {
                throw new NotFoundException();
            }

            var updateEmitente = Mapper.Map(emitente, _emitente);

            return(_repository.Update(updateEmitente));
        }