public User ValidateUser(string userName, string password) { var encryptedPassword = _webHelper.EncryptToMd5(password); var user = _unitOfWork.UserRepository.Table() .FirstOrDefault(x => x.Username == userName && x.Password == encryptedPassword); if (user != null) { user.LastActivity = System.DateTime.Now; _unitOfWork.UserRepository.Update(user); _unitOfWork.Save(); } return(user); }