Esempio n. 1
0
        public async Task <IActionResult> PutTipo(int id, Tipo tipo)
        {
            if (id != tipo.Id)
            {
                return(BadRequest());
            }

            _context.Entry(tipo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TipoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutEvento(int id, Evento evento)
        {
            if (id != evento.Id)
            {
                return(BadRequest());
            }

            _context.Entry(evento).State = EntityState.Modified;

            Local local = _context.Locais.Find(evento.LocalId);

            local.NomeLocal  = evento.Local.NomeLocal;
            local.Morada     = evento.Local.Morada;
            local.Localidade = evento.Local.Localidade;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EventoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task UpdateEvento(int id, Evento model)
        {
            var evento = _eventoDbContext.Eventos.SingleOrDefault(e => e.Id == id);

            if (evento == null)
            {
                throw new ArgumentException("Usuario não encontrado!!");
            }

            evento.Update(model.Local, model.DataEvento, model.Tema, model.QtdPessoas, model.ImageUrl, model.Telefone, model.Email);
            await _eventoDbContext.SaveChangesAsync();
        }
Esempio n. 4
0
        public async Task DeleteRedeSocial(int id)
        {
            var redeSocial = _eventoDbContext.RedeSociais.SingleOrDefault(r => r.Id == id);


            if (redeSocial == null)
            {
                throw new ArgumentException("Rede Social não encotrada");
            }

            _eventoDbContext.RedeSociais.Remove(redeSocial);
            await _eventoDbContext.SaveChangesAsync();
        }
        public async Task <bool> Delete(int idEvento, int id)
        {
            var lote = _eventoDbContext.Lotes.SingleOrDefault(l => l.EventoId == idEvento && l.Id == id);

            if (lote == null)
            {
                throw new ArgumentException("usuário não encontrado");
            }
            _eventoDbContext.Lotes.Remove(lote);

            return(await _eventoDbContext.SaveChangesAsync() == 1 ? true : false);
        }