Esempio n. 1
0
        public Palestra(string titulo, string resumo, Palestrante palestrante)
        {
            Titulo = titulo;
            Resumo = resumo;
            Palestrante = palestrante;

            palestrante.Registrar(this);
        }
Esempio n. 2
0
        public HttpResponseMessage PostPalestrante(Palestrante palestrante)
        {
            if (ModelState.IsValid)
            {
                db.Palestrantes.Add(palestrante);
                db.SaveChanges();

                var response = Request.CreateResponse(HttpStatusCode.Created, palestrante);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = palestrante.Id }));
                return(response);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Esempio n. 3
0
 public async Task <IActionResult> Post(Palestrante model)
 {
     try
     {
         this.Repo.Add(model);
         if (await this.Repo.SaveChengesAsync())
         {
             return(Created($"api/palestrentes/{model.Id}", model));
         }
     }
     catch (System.Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
     return(BadRequest());
 }
Esempio n. 4
0
 async Task <Palestrante> IPalestranteService.AddPalestrante(Palestrante model)
 {
     try
     {
         _geralPersistence.Add <Palestrante>(model);
         if (await _geralPersistence.SaveChangesAsync())
         {
             return(await _palestratePersistence.GetPalestranteByIdAsync(model.Id, false));
         }
         return(null);
     }
     catch (System.Exception e)
     {
         throw new System.Exception(e.Message);
     }
 }
Esempio n. 5
0
 public async Task <IActionResult> Post(Palestrante model)
 {
     try
     {
         _repositorio.Add(model);
         if (await _repositorio.SaveChangesAsync())
         {
             return(Created($"/api/evento/{model.Id}", model));
         }
         return(BadRequest());
     }
     catch (System.Exception ex)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
Esempio n. 6
0
        private void LoadDesignData()
        {
            Palestrante = new Palestrante("Elemar Jr", "http://qconsp.com/images/palestrantes/elemar-junior.jpg?1339080693")
            {
                Bio     = @"Elemar Júnior. Gerente de Pesquisa e Desenvolvimento na Promob. Na empresa há 14 anos. Desenvolve usando tecnologias Microsoft desde sua infância. Utiliza .net desde sua primeira versão. Em 2012, foi reconhecido como Microsoft MVP em C#. Especialista em computação gráfica, CAD e CAM.",
                Twitter = "elemarjr",
                Id      = 1
            };

            UltimosTweets.Add(new Tweet()
            {
                created_at = DateTime.Now,
                source     = "here",
                text       = "Passamos de 100.000 downloads na google play com o app Dieta e Saúde… no itunnes já passamos de 700.00 #rocks"
            });
        }
Esempio n. 7
0
 public async Task <IActionResult> Post(Palestrante model)
 {
     try
     {
         _repo.Add(model);
         if (await _repo.SaveChangesAsync())
         {
             return(Created($"/api/palestrante/{model.Id}", model));
         }
     }
     catch (Exception)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, "Falha na conexão com o banco de dados"));
     }
     return(BadRequest());
 }
Esempio n. 8
0
 public async Task <IActionResult> Post(Palestrante model)
 {
     try
     {
         _repo.Add(model);
         if (await _repo.SaveChangesAsync())
         {
             return(Created("/palestrante/{model.Id}", model));
         }
     }
     catch (System.Exception)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou"));
     }
     return(BadRequest());
 }
Esempio n. 9
0
 public async Task <Palestrante> AddPalestrantes(Palestrante model)
 {
     try
     {
         _geralPersistence.Add(model);
         if (await _geralPersistence.SaveChangesAsync())
         {
             return(await _palestrantePersistence.GetPalestranteByIdAsync(model.Id, false));
         }
         return(null);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Esempio n. 10
0
        private void btCadastrar_Click(object sender, EventArgs e)
        {
            if (EmptyFields())
            {
                List <Palestrante>     LP  = new List <Palestrante>();
                List <Titulos>         LT  = new List <Titulos>();
                List <InfoPalestrante> LIP = new List <InfoPalestrante>();

                Palestrante palestrante = new Palestrante();
                palestrante.CodPalestrante  = Convert.ToInt32(tbCodPalestrante.Text.Trim());
                palestrante.NomePalestrante = tbNomePalestrante.Text;
                LP.Add(palestrante);

                if (dbo.InsertPalestrante(LP))
                {
                    Titulos titulos = new Titulos();
                    titulos.NomeInstituicaoTitulo     = tbInstituicaoTitulo.Text;
                    titulos.dataTitulo                = dDataPosse.Value.Date;
                    titulos.Titulacao_idTitulacao     = ctbTitulo.FindString(ctbTitulo.Text);
                    titulos.Palestrante_idPalestrante = dbo.LastField("palestrante", "idpalestrante");
                    LT.Add(titulos);
                }

                if (dbo.InserTitulos(LT))
                {
                    InfoPalestrante infopalestrante = new InfoPalestrante();
                    infopalestrante.TelefoneFixo = mtbTelefoneFixo.Text;
                    infopalestrante.Celular      = mTelefoneCelular.Text;
                    infopalestrante.Email        = tbEmail.Text;
                    infopalestrante.Cidade       = tbCidade.Text;
                    infopalestrante.Palestrante_idPalestrante = dbo.LastField("palestrante", "idpalestrante");
                    infopalestrante.Estados_idEstados         = cEstado.FindString(cEstado.Text) + 1;
                    LIP.Add(infopalestrante);
                }

                if (dbo.InsertInfoPalestrante(LIP))
                {
                    MessageBox.Show("Cadastro realizado com sucesso!", "Sucesso!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Ocorreu um erro! Entre em contato com o administrador.", "Erro!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 11
0
        public async Task <IActionResult> Post(Palestrante model)
        {
            try
            {
                _repository.Add(model);
                if ((await _repository.SaveChangesAsync()))
                {
                    Created($"api/Palestrante/{model.Id}", model);
                }

                return(BadRequest());
            }
            catch (System.Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados Falhou!"));
            }
        }
Esempio n. 12
0
        public async Task <IActionResult> Post(Palestrante palestrante)
        {
            try
            {
                _repo.Adicionar(palestrante);

                if (await _repo.SaveChangesAsync())
                {
                    return(Created($"api/palestrante/{palestrante.Id}", palestrante));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Ocorreu um falha ao acessar o banco de dados"));
            }
            return(BadRequest());
        }
        public async Task <IActionResult> Post([FromBody] Palestrante model)
        {
            try
            {
                _repo.Add(model);
                if (await _repo.SaveChangesAsync())
                {
                    return(Created($"/api/palestrante/{model.Id}", model));
                }
            }
            catch (Exception error)
            {
                return(BadRequest("Sistema Falhou: " + error.Message));
            }

            return(BadRequest());
        }
Esempio n. 14
0
        public async Task <IActionResult> Put(Palestrante palestrante)
        {
            try
            {
                _repo.Add(palestrante);
                if (await _repo.SaveChangesAsync())
                {
                    return(Created($"/api/palestrante/{palestrante.Id}", palestrante));
                }
            }
            catch (System.Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Ocorreu um erro no banco de dados!"));
            }

            return(BadRequest());
        }
Esempio n. 15
0
        public async Task <IActionResult> Put(int id, Palestrante model)
        {
            try
            {
                var palestrante = await _palestranteService.UpdatePalestrante(id, model);

                if (palestrante == null)
                {
                    return(BadRequest("Palestrante nao encontrado"));
                }
                return(Ok(palestrante));
            }
            catch (Exception ex)
            {
                throw new Exception("Erro: " + ex.Message);
            }
        }
Esempio n. 16
0
        public async Task <IActionResult> Post(Palestrante palestrante)
        {
            try
            {
                await _palestrantesRepository.Adicionar(palestrante);

                if (await _palestrantesRepository.Commitar())
                {
                    return(Created($"/api/palestrantes/{palestrante.Id}", palestrante));
                }
            }
            catch (System.Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Erro ao conectar ao banco de dados"));
            }
            return(BadRequest());
        }
        public async Task <IActionResult> Create(Palestrante palestrante)
        {
            try
            {
                _repository.Add(palestrante);

                if (await _repository.SaveChangesAsync())
                {
                    return(Created($"/api/palestrantes/{palestrante.Id}", palestrante));
                }
            }
            catch (ApplicationException e)
            {
                return(RedirectToAction(nameof(ErrorModel), new { message = e.Message }));
            }
            return(BadRequest());
        }
Esempio n. 18
0
        public Palestrante AtualizaPalestrante(Palestrante palestrante)
        {
            // Simula a alteracao do palestrante na lista


            var palestranteOld = this.RetornabyId(palestrante.Id);

            palestranteOld.Id     = palestrante.Id;
            palestranteOld.Email  = palestrante.Email;
            palestranteOld.RG     = palestrante.RG;
            palestranteOld.Skills = palestrante.Skills;

            // salvar as alteracoes

            //retornando o palestranteOld
            return(palestranteOld);
        }
Esempio n. 19
0
        public async Task <IActionResult> Post(Palestrante palestrante)
        {
            try
            {
                repository.Add(palestrante);

                if (await repository.SaveChangeAsync())
                {
                    return(Created($"api/Palestrante/getById/{palestrante.Id}/true", palestrante));
                }
            }
            catch (System.Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Erro no banco de dados"));
            }
            return(BadRequest());
        }
Esempio n. 20
0
        public async Task <IActionResult> Post(Palestrante model)
        {
            try
            {
                Context.Add(model);

                if (await Context.SaveChangesAsync())
                {
                    return(Created($"eventos{model.Id}", model));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Erro Interno API"));
            }

            return(BadRequest());
        }
Esempio n. 21
0
        public async Task <IActionResult> Post(Palestrante model)
        {
            try
            {
                _respository.Add(model);

                if (await _respository.SaveChangesAsync())
                {
                    return(Created($"/api/Palestrante/{model.Id}", model));
                }
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "DB failure"));
            }

            return(BadRequest());
        }
        public async Task <IActionResult> Post([FromBody] Palestrante palestranteModel)
        {
            try
            {
                _palestranteRepository.Add(palestranteModel);

                if (await _palestranteRepository.SaveChangesAsync())
                {
                    return(Created($"/api/palestrantes/{palestranteModel.Id}", palestranteModel));
                }
            }
            catch (System.Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Banco de dados falhou: {e.Message}"));
            }

            return(BadRequest());
        }
        public async Task <ActionResult> Post(Palestrante palestrante)
        {
            try{
                this.Repository.Add(palestrante);

                if (await this.Repository.SaveChangesAsync())
                {
                    return(Created($"/api/palestrante/{palestrante.ID}", palestrante));
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError, $"Ocorreu um erro durante a criação do palestrante. {ex.Message}"));
            }

            return(BadRequest());
        }
Esempio n. 24
0
        public async Task <IActionResult> Post(Palestrante model)
        {
            try
            {
                var palestrante = await _palestranteService.AddPalestrante(model);

                if (palestrante == null)
                {
                    return(BadRequest("Erro ao adicionar o palestrante"));
                }
                return(Ok(palestrante));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError,
                                       $"Erro ao tentar recuperar os palestrantes.Erro: {ex.Message}"));
            }
        }
        public async Task <IActionResult> Post(Palestrante model)
        {
            try
            {
                _proAgilRepository.Add(model);

                if (await _proAgilRepository.SaveChangesAsync())
                {
                    return(Created($"/api/Palestrante/{model}", model));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de Dados Falhou"));
            }

            return(BadRequest());
        }
Esempio n. 26
0
        public async Task <IActionResult> Post(Palestrante model)
        {
            try
            {
                _repos.Add(model);

                if (await _repos.SaveChangesAsync())
                {
                    return(Created($"/api/palestrante/{model.Id}", model));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Erro no banco"));
            }

            return(BadRequest("Erro na Requisição!!!"));
        }
Esempio n. 27
0
        public async Task <IActionResult> Post(Palestrante model)
        {
            try
            {
                _repo.Add(model);

                if (await _repo.SaveChangesAsync())
                {
                    //return this.StatusCode(StatusCodes.Status200OK, "Evento Salvo com Sucesso");
                    return(Created($"/api/palestrante/{model.PalestranteEvento}", model));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de Dados Falhou"));
            }

            return(BadRequest());
        }
Esempio n. 28
0
 public async Task <IActionResult> Put(int id, [FromBody] Palestrante model)
 {
     try
     {
         _context.Update(model);
         if (await _context.SaveChangesAsync())
         {
             return(Created($"/api/eventos/{model.Id}", model));
         }
         else
         {
             throw new Exception("Erro ao alterar evento");
         }
     }
     catch (Exception ex)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
Esempio n. 29
0
        public async Task <IActionResult> Put(int PalestranteId, Palestrante model)
        {
            try
            {
                var evento = await _repo.GetPalestranteAsync(PalestranteId, false);

                _repo.Update(model);

                if (await _repo.SaveChangesAsync())
                {
                    return(Created($"/api/palestrante/{model.Id}", model));
                }
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"{ex.Message}"));
            }
            return(BadRequest());
        }
        public async Task <IActionResult> Put(int palestranteId, Palestrante model)
        {
            try{
                var palestrante = await _repository.GetEventoAsyncById(palestranteId, false);

                if (palestrante == null)
                {
                    return(NotFound());
                }
                _repository.Update(model);
                if (await _repository.SaveChangesAsync())
                {
                    return(Created($"/api/palestrante/{model.Id}", model));
                }
            } catch (System.Exception) {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Bando de Dados Falhou"));
            }
            return(BadRequest());
        }
Esempio n. 31
0
        public async Task <IActionResult> Post(Palestrante model)
        {
            try
            {
                _repository.Add(model);

                if (await _repository.SaveChangesAsync())
                {
                    return(Created($"/api/palestrante/{model.Id}", model));
                }
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError,
                                       $"Falha ao realizar operação: ${ex.Message}"));
            }

            return(BadRequest("Houve um erro na inclusão do evento."));
        }