public async Task <ActionResult> DeleteChecklist(int id, short ver) { var checklist = await _repo.GetChecklist(id, ver); var status = checklist.Status; if (status == "Draft") { _repo.Delete(checklist); if (ver == 1) { _repo.Delete(await _repo.GetIndex(id)); } } if (await _repo.SaveAll()) { return(NoContent()); } return(BadRequest("Problem deleting checklist please try again")); }
public async Task Execute(int id) { if (id == 0) { throw new NotFoundRegisterException("CheckList não Encontrado."); } var checklist = await _repository.FindById(id); if (checklist == null) { throw new NotFoundRegisterException("CheckList não Encontrado."); } await _repository.Delete(checklist); }
public async Task <ActionResult> DeleteStep(int stepId, LogChecklistSteps step) { _repo.Delete(step); var checklist = await _repo.GetChecklist(step.Idchecklist, step.Version); var stepNum = 1; var steps = checklist.LogChecklistSteps.OrderByDescending(s => s.Step); foreach (var s in steps) { s.Step = (short)stepNum; stepNum++; } _repo.Add(FileHistory(step, "Draft", "Deleted a Step")); if (await _repo.SaveAll()) { return(NoContent()); } return(BadRequest("There was a problem deleting this step. Please try again")); }