private StepEditModel spaceStepEdit(stepModel model) { var se = new StepEditModel(); var sp = _context.TestSpace.FirstOrDefault(t => t.Id == model.spaceID); if (sp == null) { return(unknownStepEdit(model)); } var spStep = sp.spaceModel().steps.FirstOrDefault(t => t.name == model.name); if (spStep == null) { return(unknownStepEdit(model)); } se.fullName = $"{sp.Name} - {spStep.name}({spStep.describe})"; se.describe = model.describe; se.attrs = (from t in spStep.attrs select new StepEditAttrModel { name = t.name, value = model.attrs.ContainsKey(t.name)? model.attrs[t.name]:t.defValue, describe = t.describe, list = t.list }).ToList(); return(se); }
/// <summary> /// 未知步骤编辑 /// </summary> private StepEditModel unknownStepEdit(stepModel model) { var se = new StepEditModel(); se.fullName = "unknown"; se.describe = model.describe; se.attrs = (from t in model.attrs select new StepEditAttrModel { name = t.Key, value = t.Value, describe = t.Key }).ToList(); return(se); }
private StepEditModel blockStepEdit(stepModel model) { var se = new StepEditModel(); var bs = _context.BlockStep.FirstOrDefault(t => t.Id == model.blockID); if (bs == null) { return(unknownStepEdit(model)); } se.fullName = $"Block - No.{bs.Id}:{bs.Name}"; se.describe = model.describe; se.attrs = (from t in bs.blockAttrs() select new StepEditAttrModel { name = t.Key, value = model.attrs.ContainsKey(t.Key) ? model.attrs[t.Key] : t.Value, describe = t.Key }).ToList(); return(se); }
public IActionResult edit([FromBody] stepModel model) { if (model.attrs == null) { model.attrs = new Dictionary <string, string>(); //除错 } StepEditModel sem; if (model.spaceID > 0) { sem = spaceStepEdit(model); } else if (model.blockID > 0) { sem = blockStepEdit(model); } else { sem = unknownStepEdit(model); } return(PartialView("_StepEdit", sem)); }