public ActionResult Put([FromBody] Andamento andamento, int id)
        {
            try
            {
                var andamentos = _serviceAndamento.BuscarPeloId(id);


                andamentos.Descricao     = andamento.Descricao;
                andamentos.DataAndamento = andamento.DataAndamento;


                var result = _serviceAndamento.AlterarAndamento(andamentos);

                if (result == null)
                {
                    return(BadRequest("Solicitação não encontrado!"));
                }

                var AndamentoDTO = _mapper.Map <AndamentoListDTO>(result);

                return(Ok(AndamentoDTO));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #2
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            if (txtId.Text != "")
            {
                redimensionarGride();
                btnAdicionar.Enabled = !btnAdicionar.Enabled;
                btnRemover.Enabled   = !btnRemover.Enabled;

                if (txtAndamento.Visible == false)
                {
                    SGAPContexto contexto  = new SGAPContexto();
                    Andamento    andamento = new Andamento();

                    andamento.id            = Convert.ToInt32(txtId.Text);
                    andamento.descricao     = txtAndamento.Text;
                    andamento.data          = Convert.ToDateTime(dgvAndamentos.SelectedRows[0].Cells["data"].Value.ToString());
                    andamento.atendimentoID = Convert.ToInt32(dgvAndamentos.SelectedRows[0].Cells["atendimentoID"].Value.ToString());
                    try
                    {
                        if (dtpPrazo.Text == "  /  /")
                        {
                            andamento.prazo = null;
                        }
                        else
                        {
                            andamento.prazo = Convert.ToDateTime(dtpPrazo.Text);
                        }
                    }
                    catch (System.FormatException)
                    {
                        andamento.prazo = null;
                    }



                    contexto.Entry(andamento).State = EntityState.Modified;
                    contexto.SaveChanges();
                    carregaGrid(andamento.atendimentoID);
                    MessageBox.Show("Andamento editado com sucesso", "Informação!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    limparCampos();
                }
                else
                {
                    txtAndamento.Select(txtAndamento.Text.Length, 0);
                    txtAndamento.Focus();
                }
            }
            else
            {
                MessageBox.Show("Nenhum registro foi selecionado para edição", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #3
0
        //Gravar Andamento
        public void InsereAndamento(int id_video, int id_inscricao)
        {
            var       Andamento     = _context.Andamentos.Where(p => p.Id_inscricao.Equals(id_inscricao) && p.Id_video.Equals(id_video)).ToList();
            Andamento novoAndamento = new Andamento();

            if (Andamento.Count == 0)
            {
                novoAndamento.Data         = DateTime.Now;
                novoAndamento.Id_inscricao = id_inscricao;
                novoAndamento.Id_video     = id_video;

                //Salvar
                _context.Andamentos.Add(novoAndamento);
                _context.SaveChanges();
            }
        }
Exemple #4
0
        private void btnAdicionar_Click(object sender, EventArgs e)
        {
            redimensionarGride();

            if (txtAndamento.Visible)
            {
                limparCampos();
            }

            btnEditar.Enabled  = !btnEditar.Enabled;
            btnRemover.Enabled = !btnRemover.Enabled;


            txtAndamento.Focus();

            //aqui que salva no banco
            if (txtAndamento.Text != "")
            {
                SGAPContexto contexto  = new SGAPContexto();
                Andamento    andamento = new Andamento();

                andamento.descricao     = txtAndamento.Text;
                andamento.data          = DateTime.Now;
                andamento.atendimentoID = Convert.ToInt32(frmAtendimento.txtId.Text);
                try
                {
                    if (dtpPrazo.Text == "  /  /")
                    {
                        andamento.prazo = null;
                    }
                    else
                    {
                        andamento.prazo = Convert.ToDateTime(dtpPrazo.Text);
                    }
                }
                catch (System.FormatException)
                {
                    andamento.prazo = null;
                }

                contexto.Andamento.Add(andamento);
                contexto.SaveChanges();
                carregaGrid(andamento.atendimentoID);

                MessageBox.Show("Andamento incluído com sucesso", "Informação!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #5
0
        public Andamento SalvarAndamento(Andamento andamento)
        {
            try
            {
                if (andamento == null)
                {
                    throw new Exception("Não é possivel salvar um Andamento vazio");
                }

                _repositoryAndamento.Save(andamento);
                return(andamento);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #6
0
        public Andamento AlterarAndamento(Andamento c)
        {
            try
            {
                if (c == null)
                {
                    throw new Exception("Não é possivel alterar o Andamento vazio");
                }

                _repositoryAndamento.Update(c);

                return(c);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #7
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            //Shorten key length for Identity
            modelBuilder.Entity <IdentityUser>(entity => {
                entity.Property(m => m.Email).HasMaxLength(127);
                entity.Property(m => m.NormalizedEmail).HasMaxLength(127);
                entity.Property(m => m.NormalizedUserName).HasMaxLength(127);
                entity.Property(m => m.UserName).HasMaxLength(127);
            });
            modelBuilder.Entity <IdentityRole>(entity => {
                entity.Property(m => m.Name).HasMaxLength(127);
                entity.Property(m => m.NormalizedName).HasMaxLength(127);
            });
            modelBuilder.Entity <IdentityUserLogin <string> >(entity =>
            {
                entity.Property(m => m.LoginProvider).HasMaxLength(127);
                entity.Property(m => m.ProviderKey).HasMaxLength(127);
            });
            modelBuilder.Entity <IdentityUserRole <string> >(entity =>
            {
                entity.Property(m => m.UserId).HasMaxLength(127);
                entity.Property(m => m.RoleId).HasMaxLength(127);
            });
            modelBuilder.Entity <IdentityUserToken <string> >(entity =>
            {
                entity.Property(m => m.UserId).HasMaxLength(127);
                entity.Property(m => m.LoginProvider).HasMaxLength(127);
                entity.Property(m => m.Name).HasMaxLength(127);
            });


            Andamento.Map(modelBuilder);
            Solicitacao.Map(modelBuilder);
        }
        public ActionResult <Andamento> Post([FromBody] Andamento andamento)
        {
            try
            {
                if (andamento == null)
                {
                    return(NotFound("Não é possivel salvar um andamento vazio !"));
                }

                if (andamento.SolicitacaoId == 0)
                {
                    return(NotFound("Não é possivel salvar um andamento Com o Id Nulo !"));
                }

                var solicitacao = _serviceSolicitacao.BuscarPeloId(andamento.SolicitacaoId);

                if (solicitacao == null)
                {
                    return(NotFound("Não é possivel salvar um andamento com ID vazio !"));
                }


                var retorno = _serviceAndamento.SalvarAndamento(andamento);

                if (retorno == null)
                {
                    return(BadRequest("Erro ao Salvar"));
                }

                return(Ok(andamento));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #9
0
 public void QuandoVerificarAPosicaoDoAndamento()
 => andamento = assunto.Posicao;