Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @modelIEnumerable<MyApp.Models.ComputerDetail>
- @{
- ViewBag.Title = "Index";
- }
- <h2 class ="page-header">Computer Details</h2>
- <div class ="col-lg-12">
- <p>
- @Html.ActionLink("Create New", "Create", "ComputerDetail", new {id = Model.First().ComputerID}, new { @class = "btn btn-default"})
- </p>
- <div class="panel panel-default">
- <div class ="panel-body">
- <table class ="table table-striped" id="dtaTable">
- <thead class ="dataTableHead">
- <tr>
- <th>
- @Html.DisplayNameFor(model => model.ComputerID)
- </th>
- <th>
- @Html.DisplayNameFor(model => model.EmployeeID)
- </th>
- <th>
- @Html.DisplayNameFor(model => model.StartDate)
- </th>
- <th>
- @Html.DisplayNameFor(model => model.EndDate)
- </th>
- <th>
- @Html.DisplayNameFor(model => model.Comments)
- </th>
- <th>Actions</th>
- </tr>
- </thead>
- @foreach (var item in Model) {
- <tr>
- <td>
- @Html.DisplayFor(modelItem => item.ComputerID)
- </td>
- <td>
- @Html.DisplayFor(modelItem => item.Employee.FullName)
- </td>
- <td>
- @Html.DisplayFor(modelItem => item.StartDate)
- </td>
- <td>
- @Html.DisplayFor(modelItem => item.EndDate)
- </td>
- <td>
- @Html.DisplayFor(modelItem => item.Comments)
- </td>
- <td>
- @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
- @Html.ActionLink("Details", "Details", new { id=item.ID }) |
- @Html.ActionLink("Delete", "Delete", new { id=item.ID })
- </td>
- </tr>
- }
- </table>
- </div>
- </div>
- </div>
- public ActionResult Index(int id)
- {
- var _FindComputerID = GetComputerDetails(id);
- return View(_FindComputerID);
- }
- private List<ComputerDetail>GetComputerDetails(int id)
- {
- var FindComputerID = db.ComputerDetails.Where(cd => cd.ComputerID == id).Include
- (cd => cd.Employee).OrderByDescending(cd => cd.ID);
- return FindComputerID.ToList();
- }
- [HttpGet]
- public ActionResult Create(int id)
- {
- ComputerDetail computerdetail = new ComputerDetail ();
- computerdetail.ComputerID = id;
- return View(computerdetail);
- }
- public class ComputerDetail
- {
- [Key]
- [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public int ID { get; set; }
- [Required(ErrorMessage = "Please enter service tag")]
- [Display(Name = "Service Tag")]
- public int ComputerID { get; set; }
- [Required(ErrorMessage = "Please select employee name")]
- [Display(Name = "Employee Name")]
- public int EmployeeID { get; set; }
- [Required(ErrorMessage = "Please enter date")]
- [Display(Name = "Date Bought")]
- [DataType(DataType.Date)]
- public DateTime StartDate { get; set; }
- [Display(Name = "Date Bought")]
- [DataType(DataType.Date)]
- public DateTime? EndDate { get; set; }
- public string Comments { get; set; }
- //references
- public virtual Assets.Computer Computer { get; set; }
- public virtual Employee Employee { get; set; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement