public IActionResult Delete(long id) { if (context.FindById(id) == null) { return(NotFound()); } context.Delete(id); return(NoContent()); }
public ViewModelProgram Delete(ViewModelProgram vProgram) { try { _iProgramRepository.Delete(vProgram.Id); _iProgramRepository.Save(); return(vProgram); } catch (Exception e) { return(null); } }
public void Remove(Program Program) { _programRepository.Delete(Program); _unitOfWork.Commit(); }
private bool delete(MEPatientProgram mePP, DeletePatientProgramDataRequest request, IProgramRepository ppRepo, out DeletedPatientProgram deletedProgram) { DeletedPatientProgram deletedPatientProgram = null; List <string> deletedResponsesIds = null; bool success = false; try { if (mePP != null) { IProgramRepository ppAttributesRepo = Factory.GetRepository(request, RepositoryType.PatientProgramAttribute); IProgramRepository ppResponsesRepo = Factory.GetRepository(request, RepositoryType.PatientProgramResponse); #region PatientProgram request.Id = mePP.Id.ToString(); ppRepo.Delete(request); deletedPatientProgram = new DeletedPatientProgram { Id = request.Id }; success = true; deletedResponsesIds = new List <string>(); #endregion #region PPAttributes MEProgramAttribute pa = ppAttributesRepo.FindByPlanElementID(request.Id) as MEProgramAttribute; if (pa != null) { DeletePatientProgramAttributesDataRequest deletePPAttrDataRequest = new DeletePatientProgramAttributesDataRequest { Context = request.Context, ContractNumber = request.ContractNumber, Id = pa.Id.ToString(), UserId = request.UserId, Version = request.Version }; ppAttributesRepo.Delete(deletePPAttrDataRequest); deletedPatientProgram.PatientProgramAttributeId = deletePPAttrDataRequest.Id; success = true; } #endregion #region PPResponses List <Module> modules = mePP.Modules; if (modules != null && modules.Count > 0) { modules.ForEach(m => { List <MongoDB.DTO.Action> actions = m.Actions; if (actions != null && actions.Count > 0) { actions.ForEach(a => { List <Step> steps = a.Steps; if (steps != null && steps.Count > 0) { steps.ForEach(s => { List <MEPatientProgramResponse> meResponses = ppResponsesRepo.FindByStepId(s.Id.ToString()) as List <MEPatientProgramResponse>; if (meResponses != null && meResponses.Count > 0) { meResponses.ForEach(r => { DeletePatientProgramResponsesDataRequest deletePPResponsesRequest = new DeletePatientProgramResponsesDataRequest { Context = request.Context, ContractNumber = request.ContractNumber, Id = r.Id.ToString(), UserId = request.UserId, Version = request.Version }; ppResponsesRepo.Delete(deletePPResponsesRequest); deletedResponsesIds.Add(deletePPResponsesRequest.Id); success = true; deletedPatientProgram.PatientProgramResponsesIds = deletedResponsesIds; }); } }); } }); } }); } #endregion } } catch (Exception ex) { success = false; string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Common.Helper.LogException(int.Parse(aseProcessID), ex); } deletedProgram = deletedPatientProgram; return(success); }