我有一個觀點,必須呈現兩份報告。將2個模型傳遞給可能的視圖?
我的動作:
public ActionResult TradeUKKPIShowData(SundaysInMonthViewModel model) //show actual data in the view
{
var tradesmenReportData = _reportingService.GetTradeUKKPITradesmen(model.SelectedSunday);
var jobSortedReportData = _reportingService.GetTradeUKKPIJobSorted(model.SelectedSunday);
ViewBag.jobSortedReportDate = model.SelectedSunday;
ViewBag.addJobSortedModel = jobSortedReportData;
return View(tradesmenReportData);
}
我的第一個問題是與上述動作的前兩行。我必須通過什麼? 編譯錯誤,我得到的那些線:
「TradeUK.Services.IReportingService.GetTradeUKKPITradesmen(TradeUK.Entities.Reporting.KPIResults)」有一些無效參數
所有報告中的存儲過程,需要的是日期被選擇的/週日
我SundaysInMonthViewModel:
namespace TradeUK.Admin.Web.ViewModels
{
public class SundaysInMonthViewModel
{
public IEnumerable<SelectListItem> AllSundays { set; get; }
public string SelectedSunday { set; get; }
}
}
這裏IReportingServices.cs:
種IEnumerable<KPIResults> GetTradeUKKPITradesmen(DateTime date);
IEnumerable<KPIResults> GetTradeUKKPIJobSorted(DateTime date);
和實際方法上面:
public IEnumerable<KPIResults> GetTradeUKKPITradesmen(DateTime date)
{
}
public IEnumerable<KPIResults> GetTradeUKKPIJobSorted(DateTime date)
{
}
KPIResults:
namespace TradeUK.Entities.Reporting
{
public class KPIResults
{
public virtual string Title { get; set; }
public virtual int Total { get; set; }
public virtual int Week6 { get; set; }
public virtual int Week5 { get; set; }
public virtual int Week4 { get; set; }
public virtual int Week3 { get; set; }
public virtual int Week2 { get; set; }
public virtual int Week1 { get; set; }
}
}
另一個問題是對回報(查看(tradesmenReportData,jobSortedReportData) 我能做到這一點?在實際的視圖中,我必須對循環進行foreach以顯示各組報告數據。
請幫忙? 感謝
什麼是IReportingService.GetTradeUKKPITradesmen'的'的定義,什麼是'model.SelectedSunday'的類型?不知怎的,我不認爲後者是'TradeUK.Entities.Reporting.KPIResults'。 – 2012-08-16 08:37:17