public Task Handle(UpdatePalestraCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.CompletedTask);
            }

            var palestra = new Palestra(message.Id, message.Titulo, message.Descricao, message.Data, message.PalestranteId);

            var existingPalestra = _palestraRepository.GetByTitulo(palestra.Titulo);

            if (existingPalestra != null && existingPalestra.Id != palestra.Id && existingPalestra.Data == palestra.Data)
            {
                Bus.RaiseEvent(new DomainNotification(message.MessageType, "Palestra já cadastrada!"));
                return(Task.CompletedTask);
            }

            var existingConflictPalestras = _palestraRepository.GetConflitctPalestranteDate(message.Data, message.PalestranteId);

            if (existingConflictPalestras != null && existingConflictPalestras.Id != palestra.Id)
            {
                Bus.RaiseEvent(new DomainNotification(message.MessageType, "Palestrante já possui palestra para essa data!"));
                return(Task.CompletedTask);
            }

            _palestraRepository.Update(palestra);

            if (Commit())
            {
                Bus.RaiseEvent(new PalestraUpdatedEvent(palestra.Id, palestra.Titulo, palestra.Descricao, palestra.Data, palestra.PalestranteId));
            }

            return(Task.CompletedTask);
        }
Пример #2
0
 public static void LerArquivo(List <Palestra> Palestras)
 {
     try
     {
         using (StreamReader sr = new StreamReader("Entradas.txt"))
         {
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 string[] Dados    = line.Split(';');
                 Palestra palestra = new Palestra
                 {
                     Descricao = Dados[0],
                     Duracao   = decimal.Parse(Dados[1])
                 };
                 Palestras.Add(palestra);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Arquivo não encontrado:");
         Console.WriteLine(e.Message);
     }
 }
Пример #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Palestra palestra = db.TB_PALESTRA.Find(id);

            db.TB_PALESTRA.Remove(palestra);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
        public IHttpActionResult GetAllPalestrasSimposio(int id)
        {
            if (id <= 0)
            {
                return(NotFound());
            }

            return(Ok(Palestra.GetAllPalestrasSimposio(id)));
        }
Пример #5
0
 public ActionResult Create(Palestra palestra)
 {
     if (ModelState.IsValid)
     {
         db.Palestras.Add(palestra);
         return(RedirectToAction("Index"));
     }
     LoadPalestrantesAndTracksToViewBag();
     return(View(palestra));
 }
Пример #6
0
 private void LoadDesignData()
 {
     Palestra = new Palestra()
     {
         Nome      = "Software Design no século 21",
         Descricao = @"In the last decade or so we've seen a number of new ideas added to the mix to help us effectively design our software. Patterns help us capture the solutions and rationale for using them. Refactoring allows us to alter the design of a system after the code is written. Agile methods, in particular Extreme Programming, give us a highly iterative and evolutionary approach which is particularly well suited to changing requirements and environments. Martin Fowler has been a leading voice in these techniques and will give a suite of short talks featuring various aspects about his recent thinking about how these and other developments affect our software development.",
         Horario   = DateTime.Parse("8/4/2012 9:00 AM"),
         Id        = 1
     };
 }
Пример #7
0
        public IHttpActionResult PostPalestraSimposio([FromBody] Palestra palestra)
        {
            bool check = Palestra.CreatePalestraSimposio(palestra);

            if (check)
            {
                return(Created("Palestra", palestra));
            }
            return(BadRequest());
        }
Пример #8
0
        public IHttpActionResult PostPagamentoEvento([FromBody] JObject pagamento)
        {
            long result = Palestra.CreatePagamentoEvento(pagamento);

            if (result < 0)
            {
                return(BadRequest());
            }
            return(Created("Pagamento", result));
        }
        public void ValidarAgendaPalestraLighting()
        {
            ConferenciaBusiness conferenciaBusiness = new ConferenciaBusiness();
            List <Trilha>       trilhas             =
                conferenciaBusiness.GerarTrilhas(new[] { "Rails for Python Developers lightning" }.ToList());

            Palestra palestra = trilhas.First().Manha.Palestras.FirstOrDefault();

            Assert.True(palestra.Duracao == 5);
        }
        private bool PalestraValida(Palestra palestra)
        {
            if (palestra.EhValido())
            {
                return(true);
            }

            NotificarValidacoesErro(palestra.ValidationResult);
            return(false);
        }
Пример #11
0
 public ActionResult Edit([Bind(Include = "id_palestra,titulo,dt_inicio,duracao,id_local")] Palestra palestra)
 {
     if (ModelState.IsValid)
     {
         db.Entry(palestra).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_local = new SelectList(db.TB_LOCAL, "id_local", "nome", palestra.id_local);
     return(View(palestra));
 }
Пример #12
0
        public IActionResult Create([FromBody] Palestra palestra)
        {
            if (palestra == null)
            {
                return(BadRequest());
            }

            _palestraRepositorio.Add(palestra);

            return(CreatedAtRoute("GetPalestra", new { id = palestra.IdPalestra }, palestra));
        }
Пример #13
0
 public ActionResult Edit(Palestra palestra)
 {
     if (ModelState.IsValid)
     {
         var entry = db.Entry(palestra);
         entry.State = EntityState.Modified;
         return(RedirectToAction("Index"));
     }
     LoadPalestrantesAndTracksToViewBag();
     return(View(palestra));
 }
Пример #14
0
        public ActionResult Create([Bind(Include = "id_palestra,titulo,dt_inicio,duracao,id_local")] Palestra palestra)
        {
            if (ModelState.IsValid)
            {
                db.TB_PALESTRA.Add(palestra);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_local = new SelectList(db.TB_LOCAL, "id_local", "nome", palestra.id_local);
            return(View(palestra));
        }
Пример #15
0
        public async Task <PalestraDto> Handle(CriarPalestraCommand request, CancellationToken cancellationToken)
        {
            var palestra = new Palestra(request.Tema, request.Titulo, request.DataInicial,
                                        request.Duracao, request.Local, request.OrganizadorEmail, _colisaoLocalChecker);

            await _repository.Add(palestra);

            await _unitOfWork.Commit(cancellationToken);

            // Seria dataInicial - 7 dias ou algo assim, mas coloquei daqui a 2 minutos p/ testes
            _lembreteOrganizadorScheduler.Schedule(palestra.Id, DateTimeOffset.Now + TimeSpan.FromMinutes(2));

            return(new PalestraDto(palestra.Id.Value));
        }
Пример #16
0
        // GET: Palestras/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Palestra palestra = db.TB_PALESTRA.Find(id);

            if (palestra == null)
            {
                return(HttpNotFound());
            }
            return(View(palestra));
        }
Пример #17
0
        // GET: Palestras/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Palestra palestra = db.TB_PALESTRA.Find(id);

            if (palestra == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id_local = new SelectList(db.TB_LOCAL, "id_local", "nome", palestra.id_local);
            return(View(palestra));
        }
Пример #18
0
        public IHttpActionResult PutPagamentoEvento(int idEvento, int idParticipante, [FromBody] JObject pagamento)
        {
            int result = Palestra.UpdatePagamentoEvento(idEvento, idParticipante, pagamento);

            if (result < 0)
            {
                return(BadRequest());
            }
            else if (result == 0)
            {
                return(NotFound());
            }

            return(Ok());
        }
        public void ValidarHorarioSessaoManha()
        {
            ConferenciaBusiness conferenciaBusiness = new ConferenciaBusiness();

            //É necessário duas trilhas
            List <Trilha> trilhas = conferenciaBusiness.GerarTrilhas(new[]
            {
                "Rails for Python Developers 40min"
            }
                                                                     .ToList());

            Palestra palestra = trilhas.First().Manha.Palestras.First();

            Assert.True(palestra.Horario == TimeSpan.FromHours(9));
        }
        public void ValidarHorarioSessaoTarde()
        {
            ConferenciaBusiness conferenciaBusiness = new ConferenciaBusiness();

            //É necessário duas trilhas
            List <Trilha> trilhas = conferenciaBusiness.GerarTrilhas(new[]
            {
                "Rails for Python Developers 180min",
                "Overdoing it in Python 60min"
            }
                                                                     .ToList());

            Palestra palestra = trilhas.First().Tarde.Palestras.First();

            Assert.True(palestra.Horario == TimeSpan.FromHours(13));
        }
Пример #21
0
        // POST api/Palestras
        public HttpResponseMessage PostPalestra(Palestra palestra)
        {
            if (ModelState.IsValid)
            {
                db.Palestras.Add(palestra);
                db.SaveChanges();

                var response = Request.CreateResponse(HttpStatusCode.Created, palestra);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = palestra.Id }));
                return(response);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        /// <summary>
        ///     Gera a impressão do calendário da conferencia
        /// </summary>
        /// <param name="trilhas">Trilhas da conferencia</param>
        /// <returns></returns>
        public List <string> GerarImpressaoTrilhas(List <Trilha> trilhas)
        {
            List <string> trilhasImpressao = new List <string>();

            foreach (Trilha trilha in trilhas)
            {
                trilhasImpressao.Add($"Track {trilha.NumeroTrilha}:");

                //Sessão da manhã inícia as 9
                trilhasImpressao.AddRange(this.GerarImpressaoSessao(trilha.Manha));

                //Almoço deve ser ao meio dia
                string horarioAlmoco = Helper.FormatarHorario(TimeSpan.FromHours(12));
                trilhasImpressao.Add($"{horarioAlmoco} Almoço");

                //Sessão da manhã inícia as 13
                trilhasImpressao.AddRange(this.GerarImpressaoSessao(trilha.Tarde));

                //Busca a última palestra do dia para agendar o evento de networking
                Palestra ultimaPalestraDaSessaoDaTarde =
                    trilha.Tarde.Palestras.OrderByDescending(p => p.Horario).First();
                TimeSpan finalDaUltimaPalestraDaTarde =
                    ultimaPalestraDaSessaoDaTarde.Horario.Add(
                        TimeSpan.FromMinutes(ultimaPalestraDaSessaoDaTarde.Duracao));

                //Networking deve iniciar depois das 16h e antes das 17h
                string horarioNetworking;
                if (finalDaUltimaPalestraDaTarde < TimeSpan.FromHours(16))
                {
                    horarioNetworking = Helper.FormatarHorario(TimeSpan.FromHours(16));
                }
                else if (finalDaUltimaPalestraDaTarde > TimeSpan.FromHours(17))
                {
                    horarioNetworking = Helper.FormatarHorario(TimeSpan.FromHours(17));
                }
                else
                {
                    horarioNetworking = Helper.FormatarHorario(finalDaUltimaPalestraDaTarde);
                }

                trilhasImpressao.Add($"{horarioNetworking} Evento de Networking");
            }

            return(trilhasImpressao);
        }
Пример #23
0
        public Palestra GetById(int id, string emailUsuario)
        {
            SqlConnection conn;
            Palestra      palestra = null;
            String        query    = @"SELECT * FROM vPalestra 
                        LEFT JOIN vInscricao ON (vPalestra.Codigo = vInscricao.CodigoPalestra AND vInscricao.Email like @email )
                        WHERE vPalestra.Codigo = @id";

            try
            {
                conn = DatabaseConnection.GetConnection();
                SqlCommand cmd = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("id", id);
                cmd.Parameters.AddWithValue("email", emailUsuario == null?"":emailUsuario);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    palestra = new Palestra
                    {
                        Codigo = Convert.ToInt32(reader["Codigo"]),
                        CodigoTipoCategoria = Convert.ToInt32(reader["CodigoTipoCategoria"]),
                        Imagem              = reader["Imagem"].ToString(),
                        Titulo              = reader["Titulo"].ToString(),
                        Palestrante         = reader["Palestrante"].ToString(),
                        Descricao           = reader["Descricao"].ToString(),
                        Data                = reader["Data"].ToString(),
                        Hora                = reader["Hora"].ToString(),
                        QtdVagasDisponiveis = Convert.ToInt32(reader["QtdVagasDisponiveis"])
                    };
                    if (reader["DataCadastro"] != null && !reader["DataCadastro"].ToString().Equals("") && !reader["DataCadastro"].ToString().Equals("null"))
                    {
                        palestra.EmailCadastrado = emailUsuario;
                        palestra.DataInscricao   = reader["DataCadastro"].ToString();
                        palestra.HoraInscricao   = reader["HoraCadastro"].ToString();
                    }
                }
                DatabaseConnection.CloseConnection(conn);
            }
            catch (Exception e)
            {
                return(null);
            }
            return(palestra);
        }
        public static void Cronograma(List <Palestra> palestras, ref string cronograma1, ref string cronograma2)
        {
            StringBuilder trilha1     = new StringBuilder();
            StringBuilder trilha2     = new StringBuilder();
            DateTime      horaTrilha1 = new DateTime(2018, 12, 12, 9, 0, 0);
            DateTime      horaTrilha2 = new DateTime(2018, 12, 12, 9, 0, 0);

            Palestra[] aux = new Palestra[100];
            palestras.CopyTo(aux);
            List <Palestra> listAux = aux.ToList();

            listAux.RemoveAll(x => x == null);

            AjustaCronograma(ref listAux, ref horaTrilha1, ref horaTrilha2, ref trilha1, ref trilha2, palestras, 0, 0);

            cronograma1 = trilha1.ToString();
            cronograma2 = trilha2.ToString();
        }
Пример #25
0
        // PUT api/Palestras/5
        public HttpResponseMessage PutPalestra(int id, Palestra palestra)
        {
            if (ModelState.IsValid && id == palestra.Id)
            {
                db.Entry(palestra).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                } catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, palestra));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Пример #26
0
        public IActionResult Update(long id, [FromBody] Palestra palestra)
        {
            if (palestra == null || palestra.IdPalestra != id)
            {
                return(BadRequest());
            }

            var _palestra = _palestraRepositorio.Find(id);

            if (palestra == null)
            {
                return(NotFound());
            }

            _palestra.DataPalestra    = palestra.DataPalestra;
            _palestra.DiretorPalestra = palestra.DiretorPalestra;
            _palestra.Palestrante     = palestra.Palestrante;
            _palestra.TemaPalestra    = palestra.TemaPalestra;
            _palestra.Semana          = palestra.Semana;

            _palestraRepositorio.Update(_palestra);
            return(new NoContentResult());
        }
Пример #27
0
        public Palestra GetById(int id)
        {
            SqlConnection conn;
            Palestra      palestra = null;
            String        query    = "SELECT * FROM vPalestra WHERE Codigo = @id";

            try
            {
                conn = DatabaseConnection.GetConnection();
                SqlCommand cmd = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("id", id);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    palestra = new Palestra
                    {
                        Codigo = Convert.ToInt32(reader["Codigo"]),
                        CodigoTipoCategoria = Convert.ToInt32(reader["CodigoTipoCategoria"]),
                        Imagem              = reader["Imagem"].ToString(),
                        Titulo              = reader["Titulo"].ToString(),
                        Palestrante         = reader["Palestrante"].ToString(),
                        Descricao           = reader["Descricao"].ToString(),
                        Data                = reader["Data"].ToString(),
                        Hora                = reader["Hora"].ToString(),
                        QtdVagasDisponiveis = Convert.ToInt32(reader["QtdVagasDisponiveis"])
                    };
                }
                DatabaseConnection.CloseConnection(conn);
            }
            catch (Exception e)
            {
                return(null);
            }
            return(palestra);
        }
Пример #28
0
 public void Salvar(Palestra palestra)
 {
     contexto.Salvar(palestra);
 }
Пример #29
0
 public List <Palestra> Get()
 {
     return(Palestra.Listar());
 }
        public Task Update(Palestra palestra)
        {
            _context.Update(palestra);

            return(Task.CompletedTask);
        }