Aby stworzyć raport okresowy, wybieram najpierw w radiobuttonie miesięczny, kwartalny lub roczny później w dropdownlist odpowiednio miesiąc i rok, kwartał i rok lub rok. Chciałbym też dać możliwość zrobienia tego na skróty i wybrania po prostu Ostatni miesiąc, Bierzący miesiąc itp. Tak to wygląda:
public class CreateReportViewModel
{
public IEnumerable<SelectListItem> Years { get; set; }
public IEnumerable<SelectListItem> Months { get; set; }
public IEnumerable<SelectListItem> Quarters { get; set; }
public ReportPeriod Period { get; set; }
}
public enum ReportPeriod
{
Years,
Months,
Quarters,
CurrentMonth,
LastMonth
}
@using (Html.BeginForm())
{
<div class="row">
<div class="col-md-2 table-bordered">
<div>
@Html.RadioButtonFor(m => m.Period, ReportPeriod.Months)
</div>
<div>
@Html.RadioButtonFor(m => m.Period, ReportPeriod.Quarters)
</div>
<div>
@Html.RadioButtonFor(m => m.Period, ReportPeriod.Years)
</div>
</div>
<div class="col-md-2 table-bordered">
//tu będą dropdownlisty
</div>
<div class="col-md-2 col-md-offset-1 table-bordered">
<p>
@Html.ActionLink("Bierzący miesiąc", "ShowReport", new { reportPeriod = ReportPeriod.CurrentMonth}, htmlAttributes: new {@class = "btn btn-default"})
</p>
<p>
@Html.ActionLink("Ostatni miesiąc", "ShowReport", new { reportPeriod = ReportPeriod.LastMonth }, htmlAttributes: new { @class = "btn btn-default" })
</p>
</div>
</div>
<div class="row">
<div class="col-md-2 col-md-offset-2 table-bordered">
<p>
<input type="submit" value="Stwórz" class="btn btn-default"/>
</p>
</div>
</div>
}
Teraz problem jest taki że rozbijam to na 2 kontrolery, submitem idzie do jednego, a ActionLink do drugiego. Mogę jakoś zamienić te ActionLinki
na submit? I zrobić tak żeby klikając w nie ustawiał się Period
w ViewModelu? Czy może jeszcze inaczej to zrobić?