public static void DeleteSession()
    {
        int IdSessao = GlobalController.instance.session.idSessao;

        List <Exercicio> allExercises = Exercicio.Read();
        bool             deleted      = false;

        foreach (var exercise in allExercises)
        {
            if (exercise.idSessao == IdSessao)
            {
                GlobalController.instance.exercise = exercise;

                if (!deleted)
                {
                    deleted = true;

                    var slashedString     = exercise.pontosExercicio.Split('/');
                    var sessionFolderName = slashedString[1];

                    string pathSession = string.Format("{0}/Exercicios/{1}", Application.dataPath, sessionFolderName);

                    if (Directory.Exists(pathSession))
                    {
                        Directory.Delete(pathSession);
                    }
                }

                DeleteExerciseButton.DeleteExercise();
            }
        }

        Sessao.DeleteValue(IdSessao);
        Flow.StaticPatient();
    }
    public static void DeletePatient()
    {
        int IdPaciente = GlobalController.instance.user.idPaciente;
        int IdPessoa   = GlobalController.instance.user.persona.idPessoa;

        string nomePessoa = (GlobalController.instance.user.persona.nomePessoa).Replace(' ', '_');
        string nomePasta  = string.Format("Assets/Exercicios/{1}-{2}", Application.dataPath, IdPessoa, nomePessoa);

        List <Sessao>               allSessions  = Sessao.Read();
        List <Exercicio>            allExercises = Exercicio.Read();
        List <PontosRotuloPaciente> allPrps      = PontosRotuloPaciente.Read();

        foreach (var exercise in allExercises)
        {
            if (exercise.idPaciente == IdPaciente)
            {
                foreach (var prp in allPrps)
                {
                    if (prp.idExercicio == exercise.idExercicio)
                    {
                        PontosRotuloPaciente.DeleteValue(prp.idRotuloPaciente);
                    }
                }

                Exercicio.DeleteValue(exercise.idExercicio);
            }
        }

        foreach (var session in allSessions)
        {
            if (session.idPaciente == IdPaciente)
            {
                Sessao.DeleteValue(session.idSessao);
            }
        }

        Paciente.DeleteValue(IdPaciente);
        Pessoa.DeleteValue(IdPessoa);
        if (Directory.Exists(nomePasta))
        {
            Directory.Delete(nomePasta, true);
        }

        Flow.StaticNewPatient();
    }
示例#3
0
        public static void TestSessionDeleteValue()
        {
            using (var conn = new SqliteConnection(GlobalController.path))
            {
                conn.Open();

                Pessoa.Insert("patient name1", "m", "1995-01-01", "6198732711", null);
                Pessoa.Insert("patient name2", "m", "1995-01-02", "6198732712", null);
                Pessoa.Insert("patient name3", "m", "1995-01-03", "6198732713", null);
                Pessoa.Insert("physio name1", "m", "1995-01-04", "6198732714", null);
                Pessoa.Insert("physio name2", "m", "1995-01-05", "6198732715", null);
                Pessoa.Insert("physio name3", "m", "1995-01-06", "6198732716", null);

                Fisioterapeuta.Insert(4, "abracadabra1", "demais1", null, null);
                Fisioterapeuta.Insert(5, "abracadabra2", "demais2", null, null);
                Fisioterapeuta.Insert(6, "abracadabra3", "demais3", null, null);

                Paciente.Insert(1, null);
                Paciente.Insert(2, null);
                Paciente.Insert(3, null);

                Sessao.Insert(1, 1, "2018-03-01", null);
                Sessao.Insert(2, 2, "2018-03-02", "procedimento2");
                Sessao.Insert(3, 3, "2018-03-03", "procedimento3");

                var check = "SELECT EXISTS(SELECT 1 FROM 'SESSAO' WHERE \"idSessao\" = \"1\" LIMIT 1)";

                var result = 0;
                using (var cmd = new SqliteCommand(check, conn))
                {
                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        try
                        {
                            while (reader.Read())
                            {
                                if (!reader.IsDBNull(0))
                                {
                                    result = reader.GetInt32(0);
                                }
                            }
                        }
                        finally
                        {
                            reader.Dispose();
                            reader.Close();
                        }
                    }
                    cmd.Dispose();
                }

                Assert.AreEqual(result, 1);
                Sessao.DeleteValue(1);

                result = 0;
                using (var cmd = new SqliteCommand(check, conn))
                {
                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        try
                        {
                            while (reader.Read())
                            {
                                if (!reader.IsDBNull(0))
                                {
                                    result = reader.GetInt32(0);
                                }
                            }
                        }
                        finally
                        {
                            reader.Dispose();
                            reader.Close();
                        }
                    }
                    cmd.Dispose();
                }

                Assert.AreEqual(result, 0);

                conn.Dispose();
                conn.Close();
            }
        }
示例#4
0
    public static void DeletePhysiotherapist()
    {
        int IdFisioterapeuta = GlobalController.instance.admin.idFisioterapeuta;
        int IdPessoa         = GlobalController.instance.admin.persona.idPessoa;

        string nomePessoa = (GlobalController.instance.admin.persona.nomePessoa).Replace(' ', '_');
        string nomePasta  = string.Format("{0}/Movimentos/{1}-{2}", Application.dataPath, IdPessoa, nomePessoa);

        List <Movimento> allMovements            = Movimento.Read();
        List <Sessao>    allSessions             = Sessao.Read();
        List <PontosRotuloFisioterapeuta> allPRF = PontosRotuloFisioterapeuta.Read();
        List <Exercicio>        allExercises     = Exercicio.Read();
        List <MovimentoMusculo> allMovMuscles    = MovimentoMusculo.Read();

        foreach (var movements in allMovements)
        {
            if (movements.idFisioterapeuta == IdFisioterapeuta)
            {
                foreach (var prf in allPRF)
                {
                    if (prf.idMovimento == movements.idMovimento)
                    {
                        PontosRotuloFisioterapeuta.DeleteValue(prf.idRotuloFisioterapeuta);
                    }
                }

                foreach (var mvm in allMovMuscles)
                {
                    if (mvm.idMovimento == movements.idMovimento)
                    {
                        MovimentoMusculo.DeleteValue(mvm.idMovimento, mvm.idMusculo);
                    }
                }

                foreach (var execises in allExercises)
                {
                    if (execises.idMovimento == movements.idMovimento)
                    {
                        Exercicio.DeleteValue(execises.idExercicio);
                    }
                }

                Movimento.DeleteValue(movements.idMovimento);
            }
        }

        foreach (var session in allSessions)
        {
            if (session.idPaciente == IdFisioterapeuta)
            {
                Sessao.DeleteValue(session.idSessao);
            }
        }

        Fisioterapeuta.DeleteValue(IdFisioterapeuta);

        if (Directory.Exists(nomePasta))
        {
            Directory.Delete(nomePasta, true);
        }

        Flow.StaticNewPhysiotherapist();
    }