public async Task <IActionResult> DeletePatientCounselling([FromBody] DeletePatientEducationCommand deletePatientEducationCommand) { if (!ModelState.IsValid) { return(BadRequest(deletePatientEducationCommand)); } var response = await _mediator.Send(deletePatientEducationCommand, Request.HttpContext.RequestAborted); if (response.IsValid) { return(Ok(response.Value)); } return(BadRequest(response)); }
public async Task <Result <DeletePatientEducationCommandResult> > Handle(DeletePatientEducationCommand request, CancellationToken cancellationToken) { using (_unitOfWork) { try { if (request.Id > 0) { var patientEducation = await _unitOfWork.Repository <PatientEducation>().Get(x => x.Id == request.Id) .FirstOrDefaultAsync(); if (patientEducation != null) { patientEducation.DeleteFlag = true; _unitOfWork.Repository <PatientEducation>().Update(patientEducation); educationresultId = 1; await _unitOfWork.SaveAsync(); } else { educationresultId = 0; } } else { educationresultId = 0; } return(Result <DeletePatientEducationCommandResult> .Valid(new DeletePatientEducationCommandResult() { PatientCounsellingId = educationresultId })); } catch (Exception ex) { Log.Error(ex.Message); return(Result <DeletePatientEducationCommandResult> .Invalid(ex.Message)); } } }