Example #1
0
        public ActionResult <PrescriptionTreatment> GetPrescriptionTreatment(int id)
        {
            PrescriptionTreatment prescriptionTreatment = _db.PrescriptionTreatments.FirstOrDefault(e => e.Id == id);

            if (prescriptionTreatment == null)
            {
                return(NotFound());
            }

            return(Ok(prescriptionTreatment));
        }
Example #2
0
        public ActionResult <PrescriptionTreatment> UpdatePrescriptionTreatment([FromBody] PrescriptionTreatment prescriptionTreatment)
        {
            if (!_db.PrescriptionTreatments.Any(e => e.Id == prescriptionTreatment.Id))
            {
                return(NotFound());
            }

            _db.PrescriptionTreatments.Update(prescriptionTreatment);
            _db.SaveChanges();

            return(Ok(prescriptionTreatment));
        }
Example #3
0
        public IActionResult DeletePrescriptionTreatment(int id)
        {
            PrescriptionTreatment prescriptionTreatment = _db.Find <PrescriptionTreatment>(id);

            if (prescriptionTreatment == null)
            {
                return(NotFound());
            }

            _db.PrescriptionTreatments.Remove(prescriptionTreatment);
            _db.SaveChanges();

            return(Ok());
        }
Example #4
0
        public ActionResult <PrescriptionTreatment> PostPrescriptionTreatment([FromBody] PrescriptionTreatment prescriptionTreatment)
        {
            PrescriptionTreatment oldPrescriptionTreatment = _db.Find <PrescriptionTreatment>(prescriptionTreatment.Id);

            if (oldPrescriptionTreatment != null)
            {
                return(BadRequest());
            }

            _db.PrescriptionTreatments.Add(prescriptionTreatment);
            _db.SaveChanges();

            return(Ok(prescriptionTreatment));
        }