0
私はフィルタとニュース記事のリストを表示する新しいスタートページに取り組んでいます。各ニュースポストと各ニュースリストは、複数のビジネスエリアでタグ付けすることができます。フォームの値をコントローラに取得するには
- 管理者によって変更することができnewslistの設定:
newslistはに従ってニュースを含んでいます。
- 次に、ページのフィルタフォームでフィルタリングします。
- フィルタが空でもユーザーがログインしている場合は、ユーザーの設定でフィルタリングされます。
ビューIndexSecondがロードされると、フィルタはそのnewslistに応じて選択可能なビジネス領域を取得します。私の問題は、選択したビジネスエリアをEditorFor
からmodel.filteredBAs
に、どのようにしてIndexSecondFiltered
に渡すのかを知りません。
IndexSecondFilteredのブレークポイントに来ると、model
は常にnullです。ビューで
は、私は同僚からの助けを得
@model Slussen.BLL.Models.PostFilterListModel
...
@using (Html.BeginForm("IndexSecondFiltered", "Home", new { model = model }))
{
@Html.HiddenFor(model => model.filteredBAs)
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="col-sm-2">Business area</div>
<div class="col-md-10">
@Html.EditorFor(model => Model.newslistModel.BusinessAreas,
new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Go" class="btn btn-primary orange" />
</div>
</div>
}
にHomeControllerで
public ActionResult IndexSecond()
{
//Known user?
int? uo = null;
if (User.Identity.IsAuthenticated)
uo = CurrentUser.UserOrganization.Id;
return View(
_queryDispatcher.Execute<PostFilterListModel>(
new GetFilteredNewsListById(1, uo, "", 1,
new System.Collections.Generic.List<int>(),
new System.Collections.Generic.List<int>())));
}
[HttpPost]
public ActionResult IndexSecondFiltered(PostFilterListModel model)
{
//Known user?
int? uo = null;
if (User.Identity.IsAuthenticated)
uo = CurrentUser.UserOrganization.Id;
return View(
_queryDispatcher.Execute<PostFilterListModel>(
new GetFilteredNewsListById(1, uo, "", 1,
new System.Collections.Generic.List<int>(), model.filteredBAs)));
}
あなたは 'BusinessAreas'エディタのためのあなたのコードを表示することができますテンプレート? –