Right, feels like a very noob questions but still new to all of this :)
I have a class in a library that is supposed to generate a doc based on a few variables that should be passed on from the MVC5 web app.
I looked at a couple of tutorials but I can't get my head around it so maybe I am approaching this the wrong way?
This is my model:
public class SummaryTicketsReportModel
{
public bool ServiceDesk { get; set; }
[DisplayFormat(DataFormatString = "{0:DD/MM/YYYY", ApplyFormatInEditMode = true)]
[DataType(DataType.Date)]
[DisplayName("From")]
public DateTime StartDate { get; set; }
[DisplayFormat(DataFormatString = "{0:DD/MM/YYYY", ApplyFormatInEditMode = true)]
[DataType(DataType.Date)]
[DisplayName("From")]
public DateTime EndDate { get; set; }
//Do I need this?
//public SummaryTicketsReportModel ()
//{
// StartDate = new DateTime();
// EndDate = new DateTime();
//}
This is my controller:
public class SummaryReportController : Controller
{
// GET: SummaryReport
public ActionResult Index()
{
return View();
}
//POST Action
[HttpPost]
public ActionResult Index(SummaryTicketsReportModel serviceDesk, SummaryTicketsReportModel startDate, SummaryTicketsReportModel endDate)
{
// takes in the view model
var selectedServiceDesk = serviceDesk;
var selectedStartDate = startDate;
var selectedEndDate = endDate;
var generateReport = new TicketSummaryReport();
//Needs to access the following: MonthSummaryReport ( ServiceDesk, StartDate, EndDate, summaryDocX)
//return generateReport.MonthsSummaryReport();
}
}
And this is my view:
@using System.Drawing
@model SummaryTicketsReportModel
@{
ViewBag.Title = "TicketsSummaryReport";
}
<h2>TicketsSummaryReport</h2>
@using (Html.BeginForm())
{
<tr>
<td>
@Html.TextBox("", String.Format("{0:d}", Model.StartDate))
</td>
<td>
@Html.TextBox("", String.Format("{0:d}", Model.EndDate))
</td>
<td style="text-align: center">
@Html.CheckBoxFor(model => model.ServiceDesk)
</td>
</tr>
<input type="submit"/>
}
SummaryTicketsReportModel
you probable want something likereturn View(generateReport.MonthsSummaryReport());