Exemplo n.º 1
0
        public PatientModel SelectIndividualRepo(PatientRequestIdModel requestId)
        {
            var cs = "Server=localhost\\SQLEXPRESS;Database=HospitalDB;Trusted_Connection=True;";

            using var con = new SqlConnection(cs); //Using Class SqlConnection for COnnent to database
            con.Open();

            string sql = string.Format(@"SELECT   a.Id
                                    ,a.Name
                                    ,a.Surname
                                    ,a.Age
                                    ,a.BirthDay
                                    ,a.TypeId
                                    ,a.NoOfVisit
                                    ,a.AppointmentDate
                                    ,a.Doctor
                                    ,b.TypeName
                        FROM PatientTbl a
                        LEFT JOIN PatientType b
                        ON a.TypeId = b.Id
                        WHERE a.[Id] = {0};
                        ", requestId.Id);

            using var cmd = new SqlCommand(sql, con); //Using Class SqlCommand for query data

            using SqlDataReader rdr = cmd.ExecuteReader();

            PatientModel output = new PatientModel();

            while (rdr.Read())

            {
                {
                    output.hn          = rdr.GetInt32(0);
                    output.name        = rdr.GetString(1);
                    output.surname     = rdr.GetString(2);
                    output.age         = rdr.GetInt32(3);
                    output.birthday    = rdr.GetDateTime(4);
                    output.typeId      = rdr.GetInt32(5);
                    output.visit       = rdr.GetInt32(6);
                    output.appointment = rdr.GetDateTime(7);
                    output.doctor      = rdr.GetString(8);
                    output.typeName    = rdr.GetString(9);
                };
            }
            return(output);
        }
Exemplo n.º 2
0
        public PatientModel SelectIndividual(PatientRequestIdModel requestId)
        {
            PatientModel result = _patientRepository.SelectIndividualRepo(requestId);

            return(result);
        }
Exemplo n.º 3
0
        public PatientModel GetIndividualPatient([FromQuery] PatientRequestIdModel requestId)
        {
            PatientModel result = _patientService.SelectIndividual(requestId);

            return(result);
        }