Beispiel #1
0
        public IActionResult Create(TipoAlocacaoModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (model.IdTipoAlocacao == 0)
                    {
                        _tipoAlocacaoService.Incluir(model);

                        ExibirMensagem("Tipo alocação cadastrada com sucesso!!", Alert.success);
                    }
                    else
                    {
                        _tipoAlocacaoService.Editar(model);

                        ExibirMensagem("Tipo alocação alterada com sucesso!!", Alert.success);
                    }
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ExibirMensagem(ex.Message, Alert.danger);
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Beispiel #2
0
        public IActionResult Create(Int32 Id)
        {
            var tipoAlocacao = _tipoAlocacaoService.ObterPorId(Id);
            TipoAlocacaoModel tipoAlocacaoModel = new TipoAlocacaoModel();

            if (tipoAlocacao != null)
            {
                tipoAlocacaoModel = new TipoAlocacaoModel()
                {
                    Cor            = tipoAlocacao.Cor,
                    DataCadastro   = tipoAlocacao.DataCadastro,
                    IdTipoAlocacao = tipoAlocacao.IdTipoAlocacao,
                    Nome           = tipoAlocacao.Nome,
                    Sigla          = tipoAlocacao.Sigla
                };
            }

            return(View(tipoAlocacaoModel));
        }