public bool IsValid(string username, string password) { using (ModelEF dsbaza = new ModelEF()) { var lista = dsbaza.SystemUsers.Where(x => @x.Active && @x.Password == @password && @x.UserName == @username).ToList(); if (lista.Count > 0) { return(true); } else { return(false); } } }
public ActionResult Login(SystemUser user) { if (ModelState.IsValid) { using (ModelEF db = new ModelEF()) { var obj = db.SystemUsers.FirstOrDefault(a => a.UserName.Equals(user.UserName) && a.Password.Equals(user.Password)); if (obj != null) { Session["UserID"] = obj.UserId.ToString(); Session["UserName"] = obj.UserName; obj.LastLogin = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index", "Home")); } TempData["msg"] = Prenosna.Poruka(PrevodSrb.Login_podaci_su_netačni_); } } return(View(user)); }
/// <summary> /// Constructor with new EF context /// </summary> public UserManipulation() { _context = _context ?? new ModelEF(); }
/// <summary> /// Constructor with new EF context /// </summary> public SolutionManipulation() { _context = _context ?? new ModelEF(); }
/// <summary> /// Constructor with new EF context /// </summary> public ProblemManipulation() { _context = _context ?? new ModelEF(); }
/// <summary> /// Constructor with new EF context /// </summary> public TypeOfRequestManipulation() { _context = _context ?? new ModelEF(); }