我正在使用 asp.net mvc3,我将实现高级搜索
这是我的高级搜索表单
@using (Html.BeginForm("AdvanceSearch","Coupon",FormMethod.Post))
{
@Html.ValidationSummary(true)
<fieldset>
<div class="editor-label">
@Html.LabelFor(model => model.AdvanceSearch.CouponName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.AdvanceSearch.CouponName)
@Html.ValidationMessageFor(model => model.AdvanceSearch.CouponName)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.AdvanceSearch.Category)
</div>
<div class="editor-field">
@Html.DropDownList("categories", new SelectList(Model.AdvanceSearch.Category.OrderBy(c=>c.Name).Select(c => c.Name)), "--- Select Categories ---")
@Html.ValidationMessageFor(model => model.AdvanceSearch.Category)
</div>
<div class="editor-label">
<div class="editor-label">
@Html.LabelFor(model => model.AdvanceSearch.CreateDate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.AdvanceSearch.CreateDate, new { @class = "picker" })
@Html.ValidationMessageFor(model => model.AdvanceSearch.CreateDate)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.AdvanceSearch.ExpiredDate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.AdvanceSearch.ExpiredDate, new { @class = "picker" })
@Html.ValidationMessageFor(model => model.AdvanceSearch.ExpiredDate)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.AdvanceSearch.PublishDate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.AdvanceSearch.PublishDate, new { @class = "picker" })
@Html.ValidationMessageFor(model => model.AdvanceSearch.PublishDate)
</div>
@Html.LabelFor(model => model.AdvanceSearch.Company)
</div>
<div class="editor-field">
@Html.DropDownList("companies", new SelectList(Model.AdvanceSearch.Company.OrderBy(c=>c.Name).Select(c => c.Name)), "--- Select Companies ---")
@Html.ValidationMessageFor(model => model.AdvanceSearch.Company)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.AdvanceSearch.Description)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.AdvanceSearch.Description)
@Html.ValidationMessageFor(model => model.AdvanceSearch.Description)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.AdvanceSearch.IsPublish)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.AdvanceSearch.IsPublish)
@Html.ValidationMessageFor(model => model.AdvanceSearch.IsPublish)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.AdvanceSearch.Active)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.AdvanceSearch.Active)
@Html.ValidationMessageFor(model => model.AdvanceSearch.Active)
</div>
<p>
<input type="submit" value="Search" />
</p>
</fieldset>
}
现在的问题是我有以下情况
- 如果只给出 CouponName 则返回所有包含指定名称的优惠券
- 如果从公司列表中选择了任何公司,那么我们将搜索该公司的所有具有指定名称的优惠券将被返回
- 如果从类别列表中选择了任何类别,那么我们将搜索该类别中具有指定名称的所有优惠券将被返回
- 如果选择了所有三个日期中的任何日期,那么我们将在该日期之前过滤优惠券
现在我很困惑,最好的方法是什么,我应该执行if else
条件,switch
还是什么?