public ActionResult Index(ComplicatedForm model) { if (ModelState.IsValidEditableFieldsOnly(model)) { return(RedirectToAction("Index")); } model.PopulateAllTestDropDownItems(); return(View(model)); }
public ActionResult Index() { var model = new ComplicatedForm(); model.ParentItemId = model.AllParentItems.Where(_ => _.Text == "Parent 2").Select(_ => Convert.ToInt32(_.Value)).First(); model.ChildItemId = model.AllChildItems.Where(_ => _.ParentValue == model.ParentItemId.ToString() && _.Value != "0") .Select(_ => Convert.ToInt32(_.Value)) .First(); model.ChildOfChildItemIds = model.AllChildOfChildItems.Where(_ => _.ParentValue == model.ChildItemId.ToString() && _.Value != "0") .Take(2) .Select(_ => Convert.ToInt32(_.Value)) .ToArray(); return(View(model)); }