Beispiel #1
0
 public void Cadastrar(Eventos evento)
 {
     using (GufosContext ctx = new GufosContext()){
         ctx.Eventos.Add(evento);
         ctx.SaveChanges();
     }
 }
 public Categorias BuscarPorId(int Id)
 {
     using (GufosContext ctx = new GufosContext())
     {
         return(ctx.Categorias.FirstOrDefault(x => x.IdCategoria == Id)); // Não é necessário ser um Id (int) pode ser alguma String ou sla
     }
 }
Beispiel #3
0
 public List <Eventos> Listar()
 {
     using (GufosContext ctx = new GufosContext())
     {
         return(ctx.Eventos.Include(x => x.IdCategoriaNavigation).ToList());
     }
 }
Beispiel #4
0
 public void Cadastrar(Categorias cat)
 {
     using (GufosContext ctx = new GufosContext()){
         ctx.Categorias.Add(cat);
         ctx.SaveChanges();
     }
 }
Beispiel #5
0
 public Usuarios BuscarUsuariosEsenha(LoginViewModel login)
 {
     using (GufosContext ctx = new GufosContext())
     {
         return(ctx.Usuarios.FirstOrDefault(x => x.Email == login.Email && x.Senha == login.Senha));
     }
 }
Beispiel #6
0
 public List <Categorias> Listar()
 {
     using (GufosContext ctx = new GufosContext())
     {
         return(ctx.Categorias.ToList());
     }
 }
 public Estilos BuscarPorId(int id)
 {
     using (GufosContext ctx = new GufosContext())
     {
         return(ctx.Estilos.FirstOrDefault(x => x.IdEstilo == id));
     }
 }
 public Usuario Logar(LoginViewModel login)
 {
     using (GufosContext _contexto = new GufosContext()){
         //Comparamos os atributos que foram modificados através do EF
         return(_contexto.Usuario.FirstOrDefault(u => u.Email == login.Email && u.Senha == login.Senha));
     }
 }
Beispiel #9
0
 public List <Eventos> Listar()
 {
     using (GufosContext ctx = new GufosContext())
     {
         return(ctx.Eventos.ToList());
     }
 }
Beispiel #10
0
 public List <Presencas> Listar()
 {
     using (GufosContext ctx = new GufosContext())
     {
         return(ctx.Presencas.Include(x => x.Evento).Include(x => x.Usuario).ToList());
     }
 }
Beispiel #11
0
 public Categorias BuscarPorId(int id)
 {
     using (GufosContext ctx = new GufosContext())
     {
         return(ctx.Categorias.FirstOrDefault(x => x.IdCategoria == id));
     }
 }
Beispiel #12
0
        public async Task <List <Usuario> > Listar()
        {
            using (GufosContext _contexto = new GufosContext()) {
                var usuarios = await _contexto.Usuario.ToListAsync();

                return(usuarios);
            }
        }
Beispiel #13
0
        public async Task <Usuario> BurcarPorId(int id)
        {
            using (GufosContext _contexto = new GufosContext()) {
                var usuario = await _contexto.Usuario.FindAsync(id);

                return(usuario);
            }
        }
Beispiel #14
0
        public async Task <Presencas> BuscarPorId(int id)
        {
            using (GufosContext _contexto = new GufosContext()){
                var presenca = await _contexto.Presencas.FindAsync(id);

                return(presenca);
            }
        }
Beispiel #15
0
 public async Task <Presenca> BuscarPorID(int id)
 {
     using (GufosContext _contexto = new GufosContext()){
         // Include e como se fosse um join, após instalarmos a biblioteca do JSON incluimos os Includes
         // Include("") = Adiciona a arvore
         return(await _contexto.Presenca.Include("Evento").Include("Usuario").FirstOrDefaultAsync(e => e.PresencaId == id));
     }
 }
Beispiel #16
0
 public async Task <TipoUsuario> Alterar(TipoUsuario tipoUsuario)
 {
     using (GufosContext _contexto = new GufosContext()){
         _contexto.Entry(tipoUsuario).State = EntityState.Modified;
         await _contexto.SaveChangesAsync();
     }
     return(tipoUsuario);
 }
Beispiel #17
0
 public async Task <Presenca> Alterar(Presenca presenca)
 {
     using (GufosContext _contexto = new GufosContext()) {
         _contexto.Entry(presenca).State = EntityState.Modified;
         await _contexto.SaveChangesAsync();
     }
     return(presenca);
 }
Beispiel #18
0
 public async Task <List <Evento> > Listar()
 {
     using (GufosContext _contexto = new GufosContext()){
         // Include e como se fosse um join, após instalarmos a biblioteca do JSON incluimos os Includes
         // Include("") = Adiciona a arvore
         return(await _contexto.Evento.Include("Categoria").Include("Localizacao").ToListAsync());
     }
 }
Beispiel #19
0
 public async Task <Evento> BuscarPorID(int id)
 {
     using (GufosContext _contexto = new GufosContext()){
         // Include e como se fosse um join, após instalarmos a biblioteca do JSON incluimos os Includes
         // Include("") = Adiciona a arvore
         return(await _contexto.Evento.Include("Categoria").Include("Localizacao").FirstOrDefaultAsync(e => e.EventoId == id));
     }
 }
 public async Task <Evento> Excluir(Evento evento)
 {
     using (GufosContext _contexto = new GufosContext()) {
         _contexto.Evento.Remove(evento);
         await _contexto.SaveChangesAsync();
     }
     return(evento);
 }
Beispiel #21
0
 public async Task <Evento> Alterar(Evento evento)
 {
     using (GufosContext _contexto = new GufosContext()){
         _contexto.Entry(evento).State = EntityState.Modified;
         await _contexto.SaveChangesAsync();
     }
     return(evento);
 }
 public async Task <Localizacao> Alterar(Localizacao localizacao)
 {
     using (GufosContext _context = new GufosContext()) {
         _context.Entry(localizacao).State = EntityState.Modified;
         await _context.SaveChangesAsync();
     }
     return(localizacao);
 }
        /// <summary>
        /// Listar todas as categorias
        /// </summary>
        /// <returns>Lista de Categorias</returns>

        public List <Categorias> Listar()
        {
            using (GufosContext ctx = new GufosContext())
            {
                ///SELECT * FROM Categorias
                return(ctx.Categorias.ToList());
            }
        }
        public async Task <Presenca> Excluir(Presenca presenca)
        {
            using (GufosContext _contexto = new GufosContext()){
                await _contexto.SaveChangesAsync();

                return(presenca);
            }
        }
Beispiel #25
0
 public async Task <List <Presenca> > Listar()
 {
     using (GufosContext _contexto = new GufosContext()){
         // Include e como se fosse um join, após instalarmos a biblioteca do JSON incluimos os Includes
         // Include("") = Adiciona a arvore
         return(await _contexto.Presenca.Include("Evento").Include("Usuario").ToListAsync());
     }
 }
 public async Task <Categoria> Excluir(Categoria categoria)
 {
     using (GufosContext _contexto = new GufosContext()){
         _contexto.Categoria.Remove(categoria);
         await _contexto.SaveChangesAsync();
     }
     return(categoria);
 }
Beispiel #27
0
        public async Task <List <Presencas> > Listar()
        {
            using (GufosContext _contexto = new GufosContext()){
                var presencas = await _contexto.Presencas.Include("Evento").ToListAsync();

                return(presencas);
            }
        }
Beispiel #28
0
        public async Task <Localizacao> BuscarPorId(int id)
        {
            using (GufosContext _contexto = new GufosContext()) {
                var localizacao = await _contexto.Localizacao.FindAsync(id);

                return(localizacao);
            }
        }
Beispiel #29
0
 public async Task <Usuario> Alterar(Usuario usuario)
 {
     using (GufosContext _context = new GufosContext()) {
         _context.Entry(usuario).State = EntityState.Modified;
         await _context.SaveChangesAsync();
     }
     return(usuario);
 }
 public async Task <Categoria> Alterar(Categoria categoria)
 {
     using (GufosContext _contexto = new GufosContext()){
         _contexto.Entry(categoria).State = EntityState.Modified;
         await _contexto.SaveChangesAsync();
     }
     return(categoria);
 }