Exemple #1
0
        public IActionResult CreatePerscription(NewPrescriptions newPre)
        {
            var pre = _dbService.CreatePerscription(newPre);

            if (pre == null)
            {
                return(BadRequest());
            }
            return(Created("", pre));
        }
Exemple #2
0
        public Prescriptions GetPerscription(int IdPrescription)
        {
            using (SqlConnection con = new SqlConnection("Data Source=db-mssql;Initial Catalog=s18687;Integrated Security=True"))
                using (SqlCommand com = new SqlCommand())
                {
                    com.Connection  = con;
                    com.CommandText = "select * from dbo.Medicament, dbo.Prescription_Medicament, dbo.Prescription where dbo.Medicament.IdMedicament = dbo.Prescription_Medicament.IdMedicament and dbo.Prescription_Medicament.IdPrescription = dbo.Prescription.IdPrescription and dbo.Prescription.IdPrescription = @id";
                    com.Parameters.AddWithValue("id", IdPrescription);
                    con.Open();
                    var           response = new NewPrescriptions();
                    SqlDataReader dr       = com.ExecuteReader();

                    while (dr.Read())
                    {
                        IdPrescription = int.Parse(dr["IdPrescription"].ToString());
                    }
                    ;
                }
            return(null);
        }
Exemple #3
0
        public NewPrescriptions CreatePerscription(NewPrescriptions newPer)
        {
            using (SqlConnection con = new SqlConnection("Data Source=db-mssql;Initial Catalog=s18687;Integrated Security=True"))
                using (SqlCommand com = new SqlCommand())
                {
                    com.Connection = con;
                    con.Open();
                    SqlTransaction transaction = con.BeginTransaction();
                    //con.BeginTransaction = transaction;

                    com.CommandText = "INSERT INTO Prescription(Date, DueDate,IdPatient, IdDoctor) VALUES(@Date, @DueDate, @IdPatient, @IdDoctor)";

                    com.Parameters.AddWithValue("Date", newPer.Date);
                    com.Parameters.AddWithValue("DueDate", newPer.DueDate);
                    com.Parameters.AddWithValue("IdPatient", newPer.IdPatient);
                    com.Parameters.AddWithValue("IdDoctor", newPer.IdDoctor);

                    com.ExecuteNonQuery();
                    transaction.Commit();
                }
            return(newPer);
        }