Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. public ActionResult Create()
  2. {
  3. ClassRepository objclassrep = new ClassRepository();
  4. DegreeRepositor objdegreerep=new DegreeRepositor();
  5. FacultyRepositor objfactulyrep=new FacultyRepositor();
  6. LessonRepository objLessonRep=new LessonRepository();
  7. MajorRepository objmajorrep=new MajorRepository();
  8. SemesterRepositor objsemesterrep=new SemesterRepositor();
  9. TeacherRepositor objteacherrep=new TeacherRepositor();
  10. ViewBag.ClassName = new SelectList(objclassrep.GetClasslist(), "Id", "ClassName");
  11. ViewBag.DegreeName = new SelectList(objdegreerep.GetDegreelist(), "Id", "DegreeName");
  12. ViewBag.FacultyName = new SelectList(objfactulyrep.GetFacultylist(), "Id", "FacultyName");
  13. ViewBag.LessonName = new SelectList(objLessonRep.GetLessonlist(), "Id", "LessonName");
  14. ViewBag.MajorName = new SelectList(objmajorrep.GetMajorlist(), "Id", "MajorName");
  15. ViewBag.TeacherName = new SelectList(objteacherrep.GetTeacherlist(), "Id", "LastName");
  16. ViewBag.SemesterName = new SelectList(objsemesterrep.GetSemesterlist(), "Id", "SemesterName");
  17.  
  18.  
  19.  
  20.  
  21.  
  22. return View("Create");
  23.  
  24. // return View();
  25. }
  26.  
  27. @model DomainClasses.Schedule
  28.  
  29. @{
  30. ViewBag.Title = "Create";
  31. }
  32.  
  33. <h2>Create</h2>
  34.  
  35. @using (Html.BeginForm()) {
  36. @Html.ValidationSummary(true)
  37.  
  38. <fieldset>
  39. <legend>Schedule</legend>
  40.  
  41. <div class="editor-label">
  42. @Html.LabelFor(model => model.TeacherId)
  43. </div>
  44. <div class="editor-field">
  45. @Html.DropDownList("TeacherName")
  46. @Html.ValidationMessageFor(model => model.TeacherId)
  47. </div>
  48.  
  49. <div class="editor-label">
  50. @Html.LabelFor(model => model.LessonId)
  51. </div>
  52. <div class="editor-field">
  53. @Html.DropDownList("LessonName")
  54. @Html.ValidationMessageFor(model => model.LessonId)
  55. </div>
  56.  
  57. <div class="editor-label">
  58. @Html.LabelFor(model => model.ClassId)
  59. </div>
  60. <div class="editor-field">
  61. @Html.DropDownList("ClassName")
  62. @Html.ValidationMessageFor(model => model.ClassId)
  63. </div>
  64.  
  65. <div class="editor-label">
  66. @Html.LabelFor(model => model.DegreeId)
  67. </div>
  68. <div class="editor-field">
  69. @Html.DropDownList("DegreeName")
  70. @Html.ValidationMessageFor(model => model.DegreeId)
  71. </div>
  72.  
  73. <div class="editor-label">
  74. @Html.LabelFor(model => model.FacultyId)
  75. </div>
  76. <div class="editor-field">
  77. @Html.DropDownList("FacultyName")
  78. @Html.ValidationMessageFor(model => model.FacultyId)
  79. </div>
  80.  
  81. <div class="editor-label">
  82. @Html.LabelFor(model => model.SemesterId)
  83. </div>
  84. <div class="editor-field">
  85. @Html.DropDownList("SemesterName")
  86.  
  87. @Html.ValidationMessageFor(model => model.SemesterId)
  88. </div>
  89.  
  90. <div class="editor-label">
  91. @Html.LabelFor(model => model.MajorId)
  92. </div>
  93. <div class="editor-field">
  94. @Html.DropDownList("MajorName")
  95. @Html.ValidationMessageFor(model => model.MajorId)
  96. </div>
  97.  
  98. <div class="editor-label">
  99. @Html.LabelFor(model => model.DateOfExame)
  100. </div>
  101. <div class="editor-field">
  102. @Html.EditorFor(model => model.DateOfExame)
  103. @Html.ValidationMessageFor(model => model.DateOfExame)
  104. </div>
  105.  
  106. <div class="editor-label">
  107. @Html.LabelFor(model => model.Capacity)
  108. </div>
  109. <div class="editor-field">
  110. @Html.EditorFor(model => model.Capacity)
  111. @Html.ValidationMessageFor(model => model.Capacity)
  112. </div>
  113.  
  114. <div class="editor-label">
  115. @Html.LabelFor(model => model.locationOfExame)
  116. </div>
  117. <div class="editor-field">
  118. @Html.EditorFor(model => model.locationOfExame)
  119. @Html.ValidationMessageFor(model => model.locationOfExame)
  120. </div>
  121.  
  122. <p>
  123. <input type="submit" value="Create" />
  124. </p>
  125. </fieldset>
  126. }
  127.  
  128. <div>
  129. @Html.ActionLink("Back to List", "Index")
  130. </div>
  131.  
  132. @section Scripts {
  133. @Scripts.Render("~/bundles/jqueryval")
  134. }
  135.  
  136. [HttpPost]
  137. public ActionResult Create(Schedule schedule)
  138. {
  139. obj.AddNewSchedule(schedule);
  140. obj.Save();
  141. return RedirectToAction("Index", "Schedule");
  142. }
  143.  
  144. @Html.DropDownListFor(x => x.ClassID, (SelectList)ViewBag.ClassName);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement