/// <summary> /// delete step by step Id /// </summary> /// <remarks> /// 1. for step id delete actions from action table /// 2. for step id delete conditions from condition table /// 3. align numbering of remaining steps /// 4. delete step from step table /// </remarks> /// <param name="step_id">step ID</param> public void DeleteStep(int step_id) { queries.DeleteStepActionsById(step_id); queries.DeleteStepConditionsById(step_id); var res = from s in DB.step where s.id == step_id select s; if (res.Count() != 1) { return; } int script_id = res.First().script_id; int step_number = res.First().step_number; var trailingSteps = from s in DB.step where (s.step_number > step_number) && (s.script_id == script_id) orderby s.step_number ascending select s; foreach (var step in trailingSteps) { step.step_number--; } queries.DeleteStepById(step_id); SaveChanges("action", "condition", "step"); Reload(); }