I am studying ASP.NET MVC5, so I made a Model
called 'ReportTagModels' containing:
public class RelatorioTagModels
{
[Key]
public int TagID { get; set; }
[Required]
public string Tag { get; set; }
[Required]
public string Vedacao { get; set; }
[Required]
public string Fluido { get; set; }
[Required]
public string Criticidade { get; set; }
[Required]
public decimal Mtbf { get; set; }
}
View of Model RelatorioTagModels
body>
<p>
@*@Html.ActionLink("Create New", "Create")*@
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Tag)
</th>
<th>
@Html.DisplayNameFor(model => model.Fluido)
</th>
<th>
@Html.DisplayNameFor(model => model.Vedacao)
</th>
<th>
@Html.DisplayNameFor(model => model.Criticidade)
</th>
<th>
@Html.DisplayNameFor(model => model.Mtbf)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<th>
@Html.DisplayFor(modelItem => item.Tag)
</th>
<td>
@Html.DisplayFor(modelItem => item.Fluido)
</td>
<td>
@Html.DisplayFor(modelItem => item.Vedacao)
</td>
<td>
@Html.DisplayFor(modelItem => item.Criticidade)
</td>
<td>
@Html.DisplayFor(modelItem => item.Mtbf)
</td>
<td>
@Html.ActionLink("Detalhes", "Index", "RelatorioRa")
</td>
</tr>
}
</table>
By Scaffoding, I generated Controller
and Views
, where, when I clicked Detalhes
, I'm directed to another table, where in this table I would like to list only the records containing% Tag
.
Then I created another model called: RelatorioTagModels
:
public class RelatorioRaModels
{
[Key]
public int RaID { get; set; }
[Required]
public string Data { get; set; }
[Required]
public string Nivel { get; set; }
[Required]
public string Nº { get; set; }
[Required]
public string Tag { get; set; }
}
That by Scaffoding, I created RelatorioRaModels
and Controller
My question is, how to list in the model Views
only the records of the selected TAG in the model RelatorioRaModels
Update:
View the model: RelatorioTagModels
WhenIclickontheRelatorioTagModels
linkonthefirstline,IwouldliketolistonlytherecordsthatbelongtotheTAG#Detalhe
,butatthemoment,itfollowsthewholetable.
Update: Method ActionResult Detail:
[Authorize]
public async Task<ActionResult> Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
RelatorioTagModels relatorioTagModels = await db.RelatorioTagModels.FindAsync(id);
if (relatorioTagModels == null)
{
return HttpNotFound();
}
return View(relatorioTagModels);
}
Update:
When I click detail in the first report ( P401-1E
) I'm directed to the RelatorioTagModels
of the second report ( Index
), where I want to show only the records that belong to that TAG.
So if I go back in the first report, I click on details of other TAG, I'm directed to the second report where I need to show only the TAG records that were selected in the first report.
It's like I made a RelatorioRaModels
in SQL. How do I WHERE
when calling the index of the WHERE
model