public bool DeleteMateria(MateriaModel materia)
        {
            var menu       = new MenuService();
            var optionMenu = new OptionMenuService();

            try
            {
                using (var context = new UniversidadeContext())
                {
                    var materiaDB = context.Materias.Where(w => w.MateriaDesc == materia.MateriaDesc).SingleOrDefault();

                    if (materiaDB != null)
                    {
                        context.Remove(materiaDB);
                        context.SaveChanges();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool DeletaNotaMateriaAluno(NotasAlunoModel notasAluno)
        {
            var optionMenu = new OptionMenuService();

            try
            {
                using (var context = new UniversidadeContext())
                {
                    var alunoNotaDB = context.NotasAlunos
                                      .Where(w => w.AlunoID == notasAluno.AlunoID &&
                                             w.MateriaID == notasAluno.MateriaID)
                                      .SingleOrDefault();


                    if (alunoNotaDB != null)
                    {
                        context.Remove(alunoNotaDB);
                        context.SaveChanges();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool VerificaMateriaCadastrada(string descMateria, out int?idMateria)
        {
            try
            {
                using (var context = new UniversidadeContext())
                {
                    var materiaDB = context.Materias
                                    .Where(w => w.MateriaDesc.ToUpper() ==
                                           descMateria.ToUpper()).SingleOrDefault();

                    if (materiaDB != null)
                    {
                        idMateria = materiaDB.MateriaID;

                        return(true);
                    }
                    else
                    {
                        Console.WriteLine("------------------------------------------");
                        Console.WriteLine("|         Matéria não cadastrada!        |");
                        Console.WriteLine("------------------------------------------");
                        Console.Write("Matéria: ");

                        idMateria = null;

                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool DeleteAluno(AlunoModel aluno)
        {
            var menu       = new MenuService();
            var optionMenu = new OptionMenuService();

            try
            {
                using (var context = new UniversidadeContext())
                {
                    var alunoDB = context.Alunos.Where(w => w.AlunoCPF == aluno.AlunoCPF).SingleOrDefault();

                    if (alunoDB != null)
                    {
                        context.Remove(alunoDB);
                        context.SaveChanges();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 protected virtual void Dispose(bool disposing)
 {
     if (_Db != null)
     {
         _Db.Dispose();
         _Db = null;
     }
 }
        public bool VizualizaNotaAluno(int AlunoID)
        {
            var optionMenu = new OptionMenuService();

            try
            {
                using (var context = new UniversidadeContext())
                {
                    var alunoNotasDB = context.NotasAlunos
                                       .Where(w => w.AlunoID == AlunoID)
                                       .ToList();

                    if (alunoNotasDB != null)
                    {
                        foreach (var item in alunoNotasDB)
                        {
                            string materiaNome = context.Materias
                                                 .Where(w => w.MateriaID == item.MateriaID)
                                                 .Select(s => s.MateriaDesc)
                                                 .SingleOrDefault();

                            Console.WriteLine("------------------------------------------");
                            Console.WriteLine(materiaNome.ToUpper() + ": " + item.notaMateria);
                            Console.WriteLine("------------------------------------------");
                        }
                        optionMenu.MenuEscolha();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool VerificaCPFAluno(string cpfAluno, out int?idAluno)
        {
            try
            {
                using (var context = new UniversidadeContext())
                {
                    var alunoDB = context.Alunos
                                  .Where(w => w.AlunoCPF ==
                                         Convert.ToInt64(cpfAluno)).SingleOrDefault();

                    if (alunoDB != null)
                    {
                        Console.WriteLine("------------------------------------------");
                        Console.WriteLine("Aluno: " + alunoDB.AlunoNome + " " + alunoDB.AlunoSobrenome);
                        Console.WriteLine("------------------------------------------");

                        idAluno = alunoDB.AlunoID;

                        return(true);
                    }
                    else
                    {
                        Console.WriteLine("------------------------------------------");
                        Console.WriteLine("|          Aluno não cadastrado!         |");
                        Console.WriteLine("------------------------------------------");
                        Console.Write("Aluno CPF: ");

                        idAluno = null;

                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 public BaseRepository(UniversidadeContext Db)
 {
     _Db = Db;
 }
Beispiel #9
0
 public RepositoryBase(UniversidadeContext dbContext)
 {
     Context = dbContext;
     DbSet   = Context.Set <TEntity>();
 }
Beispiel #10
0
 public CursosController(UniversidadeContext context) => _context = context;
Beispiel #11
0
 public EFUnitOfWork(UniversidadeContext dbContext)
 {
     _dbContext = dbContext;
 }
 public ProfessoresController(UniversidadeContext context) => _context = context;
Beispiel #13
0
 public AlunoController(UniversidadeContext db)
 {
     _alunoService = new AlunoService(db);
 }
Beispiel #14
0
 public EstudantesController(UniversidadeContext context) => _context = context;
Beispiel #15
0
 public DepartamentosController(UniversidadeContext context) => _context = context;
Beispiel #16
0
 public InicioController(UniversidadeContext contexto) => _contexto = contexto;
Beispiel #17
0
 public AlunoRepository(UniversidadeContext db) : base(db)
 {
 }
Beispiel #18
0
 public CursoRepository(UniversidadeContext dbContext)
     : base(dbContext)
 {
 }
Beispiel #19
0
 public AlunoService(UniversidadeContext db)
 {
     _alunoRepository = new AlunoRepository(db);
 }