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)); }
public ActionResult Cadastro(AgenciaCadastroViewModel model) { if (ModelState.IsValid) { agenciaAppService.Salvar(model.Agencia); } return(PartialView("_NotificationMessagesPartial")); }
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", ""); }