public async Task<ActionResult> EditProp(PropertyViewModel propView) { if (ModelState.IsValid) { var prop = propRep.FindById(propView.PId); if (prop == null) { return HttpNotFound(); } prop.ParentPid = propView.ParentPid; prop.ParentVid = propView.ParentVid; prop.PropName = propView.PropName; prop.IsKeyProp = propView.IsKeyProp; prop.IsSaleProp = propView.IsSaleProp; prop.IsPatternProp = propView.IsPatternProp; prop.IsItemProp = propView.IsItemProp; prop.IsAlias = propView.IsAlias; prop.IsRequired = propView.IsRepuired; prop.InputType = (int)propView.InputType; prop.SortOrder = propView.SortOrder; propRep.Update(prop); await uow.SaveAsync(); return RedirectToAction("PropList", new { id = propView.CatId }); } ModelState.AddModelError("", "操作失败。"); // TODO: 型形并且列表不能包含自己和自己的下属 var props = await propRep.Get(p => p.CatId == propView.CatId).ToListAsync(); props.Insert(0, new Property { PId = 0, PropName = "无" }); ViewData["SelectParentPId"] = new SelectList(props, "PId", "PropName", propView.ParentPid, new[] { propView.PId }); // TODO: 型形并且列表不能包含自己和自己的下属 var values = await valueRep.Get().ToListAsync(); values.Insert(0, new PropValue { VId = 0, ValueName = "无" }); ViewData["SelectParentVId"] = new SelectList(values, "VId", "ValueName", propView.ParentVid); ViewBag.Cid = propView.CatId; ViewBag.CName = catRep.FindById(propView.CatId).CatName; return View(propView); }
public async Task<ActionResult> CreateProp(PropertyViewModel propView) { if (ModelState.IsValid) { var prop = propRep.Create(new Property { CatId = propView.CatId, ParentPid = propView.ParentPid, ParentVid = propView.ParentVid, PropName = propView.PropName, IsKeyProp = propView.IsKeyProp, IsSaleProp = propView.IsSaleProp, IsPatternProp = propView.IsPatternProp, IsItemProp = propView.IsItemProp, IsAlias = propView.IsAlias, IsRequired = propView.IsRepuired, InputType = (int)propView.InputType, SortOrder = propView.SortOrder, Status = 1 }); await uow.SaveAsync(); return RedirectToAction("PropList", new { id = propView.CatId }); } return View(propView); }