public Usuarios GetUsuarioPorLogin(string login) { using (var db = new DBInvilliaDesafioContext()) { return(db.Usuarios.Where(x => x.Username.Trim().Equals(login.Trim())).FirstOrDefault()); } }
public Emprestimos GetEmprestimoPorIdAmigoJogo(int idAmigo, int idJogo) { using (var db = new DBInvilliaDesafioContext()) { return(db.Emprestimos.ToList().Where(x => x.IdAmigo == idAmigo && x.IdJogo == idJogo).FirstOrDefault()); } }
public IEnumerable <Usuarios> GetTodos() { using (var db = new DBInvilliaDesafioContext()) { return(db.Usuarios.ToList()); } }
public IEnumerable <Amigos> GetAmigoPorId(int id) { using (var db = new DBInvilliaDesafioContext()) { return(db.Amigos.ToList().Where(x => x.Id == id).ToList()); } }
public IEnumerable <Emprestimos> GetEmprestimoPorIdAmigo(int idAmigo) { using (var db = new DBInvilliaDesafioContext()) { return(db.Emprestimos.ToList().Where(x => x.IdAmigo == idAmigo).ToList()); } }
public Usuarios Login([FromBody] Usuarios entity) { using (var db = new DBInvilliaDesafioContext()) { return(db.Usuarios.ToList().Where(x => x.Username.Trim().Equals(entity.Username.Trim()) && x.Usersenha.Trim().Equals(entity.Usersenha.Trim())).FirstOrDefault()); } }
public IEnumerable <Amigos> GetTodos() { using (var db = new DBInvilliaDesafioContext()) { var x = db.Amigos.ToList(); return(db.Amigos.ToList()); } }
public async Task Put([FromBody] Amigos entity) { try { using (var db = new DBInvilliaDesafioContext()) { db.Entry(entity).State = EntityState.Modified; await db.SaveChangesAsync(); } } catch (Exception ex) { throw new Exception(ex.StackTrace); } }
public async Task Delete(int id) { try { Emprestimos entity; using (var db = new DBInvilliaDesafioContext()) { entity = db.Emprestimos.ToList().Where(x => x.Id == id).FirstOrDefault(); if (entity != null && entity.Id > 0) { db.Entry(entity).State = EntityState.Deleted; await db.SaveChangesAsync(); } } } catch (Exception ex) { throw new Exception(ex.StackTrace); } }
public IEnumerable <Jogos> GetJogosLivres(string livre) { using (var db = new DBInvilliaDesafioContext()) { List <Emprestimos> lstEmprestimos = db.Emprestimos.ToList(); List <Jogos> lstJogosLivres = new List <Jogos>(); foreach (var jogo in db.Jogos.ToList()) { if (lstEmprestimos != null) { if (lstEmprestimos.Any(x => x.IdJogo == jogo.Id)) { continue; } } lstJogosLivres.Add(jogo); } return(lstJogosLivres); } }
public async Task Put([FromBody] EmprestimoOrigem entity) { try { Emprestimos emp = new Emprestimos(); emp.Id = entity.Id; emp.IdAmigo = entity.IdAmigo; emp.IdJogo = entity.IdJogo; emp.DataEmprestimo = entity.DataEmprestimo; emp.IdAmigoNavigation = new Amigos(); emp.IdJogoNavigation = new Jogos(); using (var db = new DBInvilliaDesafioContext()) { //db.Entry(entity).State = EntityState.Modified; db.Entry(emp).State = EntityState.Modified; await db.SaveChangesAsync(); } } catch (Exception ex) { throw new Exception(ex.StackTrace); } }