Example #1
0
        public static async Task<Aluno> insertAluno(string login, string nome, string senha, string matricula, string turmaId)
        {
            Usuario usuario = new Usuario() { Login = login, Nome = nome, Senha = senha };
            await App.MobileService.GetTable<Usuario>().InsertAsync(usuario);

            Aluno aluno = new Aluno { Matricula = matricula, UsuarioId = usuario.Id, TurmaId = turmaId };
            await App.MobileService.GetTable<Aluno>().InsertAsync(aluno);
            return aluno;
        }
Example #2
0
        public static async void deleteAluno(Aluno aluno)
        {
            try
            {
                List<Frequencia> fs = await getAllFrequenciasToListViewByAlunoId(aluno.Id);
                foreach (Frequencia f in fs)
                {
                    List<Aula> aulas = await getAllAulasToListViewByFrequenciaId(f.Id);
                    foreach (Aula a in aulas)
                    {
                        await App.MobileService.GetTable<Aula>().DeleteAsync(a);
                    }
                    await App.MobileService.GetTable<Frequencia>().DeleteAsync(f);
                }

                List<Nota> notas = await getAllNotasToListViewByAlunoId(aluno.Id);
                foreach (Nota n in notas)
                {
                    await App.MobileService.GetTable<Nota>().DeleteAsync(n);
                }

                List<ResponsavelAluno> ras = await getAllResponsavelAlunosByAlunoId(aluno.Id);
                foreach (ResponsavelAluno ra in ras)
                {
                    await App.MobileService.GetTable<ResponsavelAluno>().DeleteAsync(ra);
                }

                await App.MobileService.GetTable<Aluno>().DeleteAsync(aluno);
                await App.MobileService.GetTable<Usuario>().DeleteAsync(new Usuario() { Id = aluno.Usuario.Id, Login = aluno.Usuario.Login, Nome = aluno.Usuario.Nome, Senha = aluno.Usuario.Senha });
            }
            catch (Exception)
            {
                await new MessageDialog("Não foi possível excluir este Professor.").ShowAsync();
            }
        }
Example #3
0
 public static async void updateAlunoBasico(Aluno aluno, Usuario usuario)
 {
     try
     {
         await App.MobileService.GetTable<Usuario>().UpdateAsync(usuario);
         aluno.Usuario = null;
         await App.MobileService.GetTable<Aluno>().UpdateAsync(aluno);
     }
     catch (Exception) { }
 }
Example #4
0
        public static async void updateAlunoCompleto(Aluno aluno, Usuario usuario)
        {
            try
            {
                await App.MobileService.GetTable<Usuario>().UpdateAsync(usuario);
                aluno.Usuario = null;
                await App.MobileService.GetTable<Aluno>().UpdateAsync(aluno);

                List<Frequencia> fs = await getAllFrequenciasToListViewByAlunoId(aluno.Id);
                foreach (Frequencia f in fs)
                {
                    List<Aula> aulas = await getAllAulasToListViewByFrequenciaId(f.Id);
                    foreach (Aula a in aulas)
                    {
                        await App.MobileService.GetTable<Aula>().DeleteAsync(a);
                    }
                    await App.MobileService.GetTable<Frequencia>().DeleteAsync(f);
                }

                List<Nota> notas = await getAllNotasToListViewByAlunoId(aluno.Id);
                foreach (Nota n in notas)
                {
                    await App.MobileService.GetTable<Nota>().DeleteAsync(n);
                }

                List<TurmaDisciplina> tds = await getAllTurmaDisciplinasByTurmaId(aluno.TurmaId);
                foreach (TurmaDisciplina td in tds)
                {
                    Frequencia nf = await insertFrequencia(aluno.Id, td.Id);
                    await insertNota(0f, 0f, 0f, aluno.Id, td.Id);
                    await insertAula(false, nf.Id);
                    await insertAula(false, nf.Id);
                    await insertAula(false, nf.Id);
                    await insertAula(false, nf.Id);
                    await insertAula(false, nf.Id);
                }
                
            }
            catch (Exception)
            {
                await new MessageDialog("Não foi possível atualizar este Aluno!").ShowAsync();
            }
        }