Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. // GET: /Dinner/Create
  2. public ActionResult Create()
  3. {
  4. ViewBag.CountryID = new SelectList(db.Countries, "CountryID", "Name");
  5. Dinner d = new Dinner() { HostedBy = User.Identity.Name.Substring(User.Identity.Name.IndexOf("\") + 1),EventDate= DateTime.Now.Date };
  6. return View(d);
  7. }
  8.  
  9. // POST: /Dinner/Create
  10.  
  11. [HttpPost]
  12. [ValidateAntiForgeryToken]
  13. public ActionResult Create([Bind(Include="Title,DinnerID,EventDate,Description,HostedBy,CountryID")] Dinner dinner)
  14. {
  15. if (ModelState.IsValid)
  16. {
  17. db.Dinners.Add(dinner);
  18. db.SaveChanges();
  19. return RedirectToAction("Index");
  20. }
  21.  
  22. dinner.Title= dinner.Title.Trim();//this will not have any effect !!!!
  23. ViewBag.CountryID = new SelectList(db.Countries, "CountryID", "Name", dinner.CountryID);
  24. return View(dinner);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement