Ejemplo n.º 1
0
        public ActionResult Salvar(List <Movimento> movimentos)
        {
            PodeInserir();
            bool sucesso = true;

            foreach (var movimento in movimentos)
            {
                try
                {
                    MovimentoApp.ProcessarNotaFaturamento(movimento,
                                                          Mapper.Map <Parametros>(ParametrosViewModel.Parametros),
                                                          Mapper.Map <LogImportacao>(new LogImportacaoViewModel()
                    {
                        DataImportacao = DateTime.Now,
                        Funcionalidade = NomePermissao,
                        Usuario        = UsuarioViewModel.UsuarioAtual,
                        NomeArquivo    = TempData[FILENAME].ToString(),
                    }));
                }
                catch (Exception ex)
                {
                    Information($"Nota fiscal {movimento.Codigo} não pode ser importada: {ex.ToInnerExceptionString()}");
                    sucesso = false;
                }
            }
            Success($"Arquivo(s) XML importado(s) com {(sucesso ? "sucesso" : "alguns erros") }.");
            return(RedirectToAction("Index"));
        }