public async Task <bool> RemovePrescriptionDetails(PrescriptionDetailsRemoveDTO prescriptionDetailsRemoveDTO) { var details = await _context.ConsultationPrescriptionDetails.FindAsync(prescriptionDetailsRemoveDTO.Id); details.Isactive = false; details.Lastchangeby = prescriptionDetailsRemoveDTO.Lastchangeby; details.Lastchangedate = DateTime.Now; if (prescriptionDetailsRemoveDTO.Comment != null) { details.Comments = prescriptionDetailsRemoveDTO.Comment; } try { var update = await _context.SaveChangesAsync(); if (update >= 1) { return(true); } else { return(false); } } catch (DbUpdateConcurrencyException) when(!PrescriptionDetailsExist(prescriptionDetailsRemoveDTO.Id)) { return(false); } }
public async Task <IActionResult> RemovePrescriptionDetails(int id, [FromBody] PrescriptionDetailsRemoveDTO prescriptionDetailsRemoveDTO) { if (id != prescriptionDetailsRemoveDTO.Id) { return(BadRequest()); } if (_pharmacyManagementRepository.PrescriptionDetailsExist(prescriptionDetailsRemoveDTO.Id) != true) { return(NotFound()); } var req = await _pharmacyManagementRepository.RemovePrescriptionDetails(prescriptionDetailsRemoveDTO); if (req == true) { return(NoContent()); } else { return(NotFound()); } }