I have to make a statistical project in C # MVC which contains several steps requiring different renderings for the user (browser, PDF document, Excel, ...) For browser part, I currently have a complex class containing a collection that serves as model for a view that displays either a table, a Chart or both.
I use @url.action to get an image of the chart I have defined a RouteValueDictionary to pass the object in url.action arguments
src="@Url.Action("SampleChart", "Statistique", Model.RouteValues ))"
In the controller: boolean and string are filled but not the dictionary(resultatsStatistique). Do you have any idea to resolve my problem ?
Below is a simplified version of the Model
public class StatisticDTO
{
public virtual string Stat_Title { get; set; }
public bool DisplayChart { get; set; }
public bool DisplayTable { get; set; }
public Dictionary<string, RowStat> resultatsStatistique;
public RouteValueDictionary RouteValues
{
get
{
var rvd = new RouteValueDictionary();
rvd["DisplayChart"] = DisplayChart;
rvd["DisplayTable"] = DisplayTable;
rvd["resultatsStatistique"] = resultatsStatistique;
return rvd;
}
}
}
public class RowStat
{
public virtual string prest_libe { get; set; }
public virtual decimal prest_effec { get; set; }
public virtual int prest_order { get; set; }
public virtual string prest_sex { get; set; }
}
Below is a simplified version of my view
@model StatisticDTO
<div>
@if (Model.DisplayChart )
{
<div>
<img src="@Url.Action("SampleChart", "Statistique", Model.RouteValues ))" />
</div>
}
@if (Model.DisplayTable)
{
@Html.Partial("_Tableau", Model)
}
</div>
Below is a simplified version of the controller
public ActionResult SampleChart(StatisticDTO modelIN)
{
(.....)
MemoryStream ms = new MemoryStream();
chart.SaveImage(ms, ChartImageFormat.Png);
return File(ms.ToArray(), "image/png");
}