Это моя ViewModel
namespace CRUD2.ViewModel
{
public class CostVM
{
public int id { get; set;}
public string nama { get; set; }
public string alamat { get; set; }
public string jenis { get; set; }
public informasi informasi { get; set; }
public iseng iseng { get; set; }
}
}
Это мой Index.cshtml
@model IEnumerable<CRUD2.ViewModel.CostVM>
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<table cellspacing="2px;">
<tr>
<th>Nama</th>
<th>Alamat</th>
<th>Jenis</th>
<th>Action</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@item.informasi.nama</td>
<td>@item.informasi.alamat</td>
<td>@item.iseng.jenis</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.informasi.id }) |
@Html.ActionLink("Back to List", "Index")
</td>
</tr>
}
</table>
</body>
</html>
и это мой контроллер (редактирование и индексирование)
namespace CRUD2.Controllers
{
public ActionResult Edit(int id = 0)
{
var costumerlist = from cust in db.informasis
join ord in db.isengs
on cust.id equals ord.id
where cust.id == id
select new { cust.nama, cust.alamat, cust.jk, cust.kelas, ord.jenis };
return View(costumerlist.FirstOrDefault());
}
}
}
Как я могу сделать свой Edit.cshtml? Я не понимаю, как это сделать, я понятия не имею, и если у меня есть какие-либо ошибки в моем коде, исправьте их. Спасибо.
Извините за мой плохой английский..