Advertisement
Guest User

Untitled

a guest
Dec 24th, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using RoosterSysteem.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7.  
  8. namespace RoosterSysteem.Controllers
  9. {
  10. public class LoginController : Controller
  11. {
  12. // GET: Login
  13. public ActionResult Index()
  14. {
  15. return View();
  16. }
  17.  
  18. //Inloggen
  19. [HttpPost]
  20. public ActionResult Autherize(RoosterSysteem.Models.User userModel)
  21. {
  22. using (ZuydDBEntities db = new ZuydDBEntities())
  23. {
  24. var userDetails = db.Users.Where(x => x.UserName == userModel.UserName && x.Password == userModel.Password).FirstOrDefault();
  25.  
  26. //inloggegevens zijn onjuist
  27. if (userDetails==null)
  28. {
  29. userModel.LoginErrorMessage = "Deze inloggegevens kloppen niet.";
  30. return View("Index", userModel);
  31. }
  32.  
  33. //inloggegevens zijn juist
  34. else
  35. {
  36. Session["userID"] = userDetails.UserID;
  37. Session["UserName"] = userDetails.UserName;
  38. return RedirectToAction("Index", "Home");
  39. }
  40. }
  41.  
  42. }
  43. //Uitloggen
  44. public ActionResult LogOut()
  45. {
  46. int userID = (int)Session["userID"];
  47. Session.Abandon();
  48. return RedirectToAction("Index", "Login");
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement