Beispiel #1
0
        public ActionResult Cadastro(int?id)
        {
            AgenciaCadastroViewModel model = new AgenciaCadastroViewModel();

            model.BancoIdPesquisado = null;

            var modelLista = Session["Filtro"] as AgenciaListaViewModel;

            if (modelLista != null && modelLista.Filtro != null)
            {
                model.BancoIdPesquisado = modelLista.Filtro.BancoId;
                model.EhValidoImprimir  = modelLista.EhValidoImprimir;
            }

            model.PodeSalvar               = agenciaAppService.EhPermitidoSalvar();
            model.PodeDeletar              = agenciaAppService.EhPermitidoDeletar();
            model.PodeImprimir             = agenciaAppService.EhPermitidoImprimir();
            model.PodeAcessarContaCorrente = agenciaAppService.EhPermitidoAcessarContaCorrente();

            var agencia = agenciaAppService.ObterPeloId(id) ?? new AgenciaDTO();

            if (id.HasValue && !agencia.Id.HasValue)
            {
                messageQueue.Add(Application.Resource.Sigim.ErrorMessages.NenhumRegistroEncontrado, TypeMessage.Error);
            }

            model.Agencia = agencia;

            CarregarCombosCadastro(model);

            return(View(model));
        }
Beispiel #2
0
 public ActionResult Cadastro(AgenciaCadastroViewModel model)
 {
     if (ModelState.IsValid)
     {
         agenciaAppService.Salvar(model.Agencia);
     }
     return(PartialView("_NotificationMessagesPartial"));
 }
Beispiel #3
0
        private void CarregarCombosCadastro(AgenciaCadastroViewModel model)
        {
            int?bancoId = null;

            if (model.Agencia != null)
            {
                bancoId = model.Agencia.BancoId;
            }

            model.ListaBanco = new SelectList(bancoAppService.ListarTodos().OrderBy(l => l.Nome).ToList(), "Id", "Nome", bancoId);

            model.ListaUnidadeFederacao = new SelectList(unidadeFederacaoAppService.ListarTodos(), "Sigla", "Sigla", "");
        }