Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. public ActionResult Create(int id)
  2. {
  3. ViewBag.id = id;
  4. ViewBag.DataFormatID = new SelectList(db.DataFormat, "DataFormatID", "FormatName");
  5. ViewBag.TCID = new SelectList(db.TC, "TCID", "TCName",id);
  6. return View();
  7. }
  8.  
  9. public class TC
  10. {
  11. public int TCID { get; set; }
  12. public string TCName { get; set; }
  13. public virtual ICollection<TCSet> TCSets { get; set; }
  14.  
  15. }
  16.  
  17. public class TCSet
  18. {
  19. public int TCSetID { get; set; }
  20. public string ValueName { get; set; }
  21. // public string DataFormat { get; set; }
  22. public DataUsage DataUsage { get; set; }
  23. public DataStatus DataStatus { get; set; }
  24. public int TCID { get; set; }
  25. public int DataFormatID { get; set; }
  26. public virtual TC TC { get; set; }
  27. public virtual DataFormat DataFormat { get; set; }
  28. }
  29.  
  30. public ActionResult ViewTCSet(int ?id)
  31. {
  32. var viewmodel = new TC_TCSet();
  33.  
  34. if(id!=null)
  35. {
  36. ViewBag.TCID = id.Value;
  37. var tcSet = db.TC.Include(x => x.TCSets).FirstOrDefault(x => x.TCID == id);
  38. if(tcSet!=null)
  39. {
  40. viewmodel.TCSet = tcSet.TCSets;
  41. }
  42. }
  43. return View(viewmodel);
  44. }
  45.  
  46. @model TCImplementation.ViewModels.TC_TCSet
  47. @{
  48. ViewBag.Title = "ViewTCSet";
  49. }
  50. <table>
  51. <tr>
  52. <th>Tc Set Name</th>
  53. <th>Data Usage</th>
  54. <th>Data Status</th>
  55. <th>Data Format</th>
  56.  
  57. </tr>
  58. @foreach(var item in Model.TCSet)
  59. {
  60. <tr>
  61. <td>@item.ValueName</td>
  62. <td>@item.DataUsage</td>
  63. <td>@item.DataStatus</td>
  64. <td>@item.DataFormat.FormatName</td>
  65. <td>@Html.ActionLink("Edit", "Edit", "TCSets", new { id= item.TCSetID},null) | @Html.ActionLink("Details", "Details", "TCSets", new { id = item.TCSetID }, null) | @Html.ActionLink("Delete", "Delete", "TCSets", new { id = item.TCSetID }, null)</td>
  66. </tr>
  67. }
  68. </table>
  69. @Html.ActionLink("Create", "Create", "TCSets", new { id = Model.TCSet }, null)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement