private void MudarDisponiblidadeDosJogos(ICadeMeuJogoContext context, ICollection <Jogo> jogos)
 {
     foreach (var jogo in jogos)
     {
         jogo.Disponivel           = !jogo.Disponivel;
         context.Entry(jogo).State = EntityState.Modified;
     }
 }
        private void RemoverJogosDoEmprestimo(ICadeMeuJogoContext context, int emprestimoId)
        {
            var emprestimosJogos = db.EmprestimosJogos;

            foreach (var empJg in emprestimosJogos)
            {
                if (empJg.EmprestimoId == emprestimoId)
                {
                    db.Entry(empJg).State = EntityState.Deleted;
                }
            }
        }
        private ICollection <Jogo> GetJogos(ICadeMeuJogoContext context, int emprestimoId)
        {
            var listaJogo        = new List <Jogo>();
            var emprestimosJogos = db.EmprestimosJogos.Include(x => x.Jogo);

            foreach (var empJg in emprestimosJogos)
            {
                if (empJg.EmprestimoId == emprestimoId && empJg.Ativo)
                {
                    listaJogo.Add(empJg.Jogo);
                }
            }
            return(listaJogo);
        }
        private void RemoverJogosDoEmprestimo(ICadeMeuJogoContext context, int emprestimoId, ICollection <Jogo> jogos)
        {
            var emprestimosJogos = db.EmprestimosJogos.Where(e => e.EmprestimoId == emprestimoId);

            foreach (var empJg in emprestimosJogos)
            {
                foreach (var jg in jogos)
                {
                    if (empJg.JogoId == jg.Id)
                    {
                        db.Entry(empJg).State = EntityState.Deleted;
                    }
                }

                //if(empJg.EmprestimoId == emprestimoId)
                //{
                //     if(jogos.FirstOrDefault(j => j.Id == empJg.JogoId).Id == empJg.JogoId)
                //    db.Entry(empJg).State = EntityState.Deleted;
                //}
            }
        }
 public EmprestimosController(ICadeMeuJogoContext context, IEmprestimoValidation validation)
 {
     db          = context;
     _validation = validation;
 }
 public JogosController(ICadeMeuJogoContext context, IJogoValidation validation)
 {
     db          = context;
     _validation = validation;
 }
 public CategoriasController(ICadeMeuJogoContext context, ICategoriaValidation validation)
 {
     this.db     = context;
     _validation = validation;
 }