I'm building a web based tool for our IT team to use to handle our IT checks and record the results.
I'm using entity framework.
Here is my object for each check to be carried out.
public class Check
{
[Key]
public int CheckID { get; set; }
//public ICollection<ITDept> ItDepts { get; set; }
//[UIHint("TeamEditor")]
public int ITDeptID { get; set; }
public string CheckName { get; set; }
public string LinkToCheck { get; set; }
public string Description { get; set; }
}
I want to create a form that will load all the checks for a given "ITDeptID".
public ActionResult LoadView(int TeamID)
{
ViewData["NeededChecks"] = _db.Checks.Where(p => p.ITDeptID == TeamID).ToList();
return View();
}
Then take that data and save it with the results of each check.
public class HistoricChecks
{
[Key]
public int Id { get; set; }
public string SentBy { get; set; }
public DateTime SentTime { get; set; }
public List<CheckLink> Checks { get; set; }
}
public class CheckLink
{
[Key]
[Column(Order = 0)]
public int CheckEntryId { get; set; }
[Key]
[Column(Order = 1)]
public int LinkedCheckID { get; set; }
public int CheckIDFromList { get; set; }
public bool PassFail { get; set; }
public string Comments { get; set; }
}
What is the best way to create a form in which there is an entry for Check assigned to the ITDeptID passed to it.
This is what I have so far.
@using AppSupportCommunicationTool.Models
@model HistoricChecks
<body>
@using (Html.BeginForm("Post", "Form", FormMethod.Post, new { @name = "MainForm" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<fieldset>
<table width="1000" align="center">
@foreach (var check in ViewData["NeededChecks"] as List<Check>)
{
<tr>
<td>
Check Name: @{ @check.CheckName }
<br />Check documentation: @{ @check.LinkToCheck }
<br />Check Description: @{ @check.Description }
</td>
<td>
@Html.EditorFor(m => m.Checks)
</td>
</tr>
}
</table>
</fieldset>
<input type="submit" />
}
</body>
I did try creating a EditorTempalte but it didn't get loaded.
Many thanks.