Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @model ExamBankSys.Models.ProposalViewModels
- <table class="table">
- <tr>
- <td>
- @Html.DisplayName("Question")
- </td>
- <td>
- @Html.DisplayName("Marks")
- </td>
- </tr>
- @foreach (var item in Model.Questions)
- {
- <tr>
- <td>
- @Html.DisplayFor(model => item.Question)
- </td>
- <td>
- @Html.DisplayFor(model => item.Marks)
- </td>
- </tr>
- }
- </table>
- public class ProposalViewModels
- {
- public int id { get; set; }
- public virtual ICollection<Question> Questions { get; set; }
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Create([Bind(Include = "id,Questions")] ProposalViewModels viewModel)
- {
- if (ModelState.IsValid)
- {
- var proposal = new Proposal
- {
- id = viewModel.id,
- Questions = viewModel.Questions,
- };
- db.Proposals.Add(proposal);
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- return View();
- }
- public ActionResult LoadQuestions(int id)
- {
- var model = new ProposalViewModels();
- model.Questions = listofQuestions();
- return PartialView("~/Views/Proposals/_Proposal.cshtml", model);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement