public async Task <ActionResult <EventoTw> > Put(EventoTw update, int id)
        {
            var evento = await repositorio.Get(id);

            if (evento.Value == null)
            {
                return(NotFound());
            }

            evento.Value.Nome        = update.Nome;
            evento.Value.Descricao   = update.Descricao;
            evento.Value.Horario     = update.Horario;
            evento.Value.Diversidade = update.Diversidade;
            evento.Value.Coffe       = update.Coffe;
            evento.Value.CategoriaId = update.CategoriaId;
            evento.Value.SalaId      = update.SalaId;

            var sucess = await repositorio.Put(evento.Value);

            if (sucess == null)
            {
                return(BadRequest("Não foi possivel atualizar"));
            }

            return(sucess);
        }
Esempio n. 2
0
        public async Task <ActionResult <EventoTw> > Delete(EventoTw evento)
        {
            try
            {
                // Mensagem(evento.EmailContato);
                await db.SaveChangesAsync();

                return(evento);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 3
0
        public async Task <ActionResult <EventoTw> > Upload(EventoTw evento)
        {
            try
            {
                db.Entry(evento).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(evento);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
        public async Task <ActionResult <EventoTw> > Put(EventoTw evento)
        {
            var categoria = await db.Categoria.Where(c => c.CategoriaId == evento.CategoriaId).FirstOrDefaultAsync();

            var sala = await db.Sala.Where(s => s.SalaId == evento.SalaId).FirstOrDefaultAsync();

            if (categoria != null && sala != null)
            {
                db.Entry(evento).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(evento);
            }
            else
            {
                return(null);
            }
        }
        public async Task <ActionResult <EventoTw> > Post(EventoTw evento)
        {
            if (!ValidaEnderecoEmail(evento.EmailContato))
            {
                return(BadRequest("Email inválido"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (evento.EventoData.Month < DateTime.Now.Month)
            {
                return(BadRequest("No momento não é possivel voltar no tempo (Mês)"));
            }
            if (evento.EventoData.Day < DateTime.Now.Day)
            {
                return(BadRequest("No momento não é possivel voltar no tempo (Dia)"));
            }

            EventoRepositorio eventoRepositorio = new EventoRepositorio();

            List <EventoTw> dataIgual           = repositorio.ExistaData(evento.EventoData).Result.Value;
            List <EventoTw> dataIgualComunidade = repositorio.ExistaData(evento.EventoData).Result.Value;


            if (dataIgual.Count > 0 || dataIgualComunidade.Count > 0)
            {
                return(BadRequest("Evento já cadastrado com essa data " + dataIgual.Count + dataIgualComunidade.Count));
            }



            return(await repositorio.Post(evento));
        }