public ActionResult <PrescriptionTreatment> GetPrescriptionTreatment(int id) { PrescriptionTreatment prescriptionTreatment = _db.PrescriptionTreatments.FirstOrDefault(e => e.Id == id); if (prescriptionTreatment == null) { return(NotFound()); } return(Ok(prescriptionTreatment)); }
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)); }
public IActionResult DeletePrescriptionTreatment(int id) { PrescriptionTreatment prescriptionTreatment = _db.Find <PrescriptionTreatment>(id); if (prescriptionTreatment == null) { return(NotFound()); } _db.PrescriptionTreatments.Remove(prescriptionTreatment); _db.SaveChanges(); return(Ok()); }
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)); }