Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. public partial class Idea
  2. {
  3. public int Idea_Id { get; set; }
  4. public string Idea_Name { get; set; }
  5. public string Technology { get; set; }
  6. public string Description { get; set; }
  7. public int dept_id { get; set; }
  8. public Nullable<int> UserID { get; set; }
  9. public string Address { get; set; }
  10.  
  11. public virtual department department { get; set; }
  12. public virtual User User { get; set; }
  13. }
  14.  
  15. public ActionResult Create()
  16. {
  17. ViewBag.dept_id = new SelectList(db.departments, "dep_id", "dep_name");
  18. ViewBag.UserID = new SelectList(db.Users, "UserID", "Username");
  19.  
  20. return View();
  21. }
  22.  
  23.  
  24. // POST: Ideas/Create
  25. // To protect from overposting attacks, please enable the specific properties you want to bind to, for
  26. // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
  27. [HttpPost]
  28. [ValidateAntiForgeryToken]
  29. public ActionResult Create([Bind(Include = "Idea_Id,Idea_Name,Technology,Start_Date,End_Date,Description,dept_id,UserID")] Idea idea)
  30. {
  31. if (ModelState.IsValid)
  32. {
  33. db.Ideas.Add(idea);
  34. db.SaveChanges();
  35. return RedirectToAction("Index");
  36. }
  37.  
  38. ViewBag.dept_id = new SelectList(db.departments, "dep_id", "dep_name", idea.dept_id);
  39. ViewBag.UserID = new SelectList(db.Users, "UserID", "Username", idea.UserID);
  40.  
  41. return View(idea);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement