コード例 #1
0
 //public List<Link> linkToShow;
 //public Link l;
 public ActionResult Index()
 {
     //int x = 1;
     ViewModel vm = new ViewModel();
     UserManager um = new UserManager(ConnectionString);
     LinkManager lm = new LinkManager(ConnectionString);
     //ViewBag.Counter = x;
     vm.Alllink = lm.GetAllLinks();
     return View(vm);
 }
コード例 #2
0
        public ActionResult Signin(string username, string password)
        {
            var mgr = new UserManager(ConnectionString);
            var user = mgr.GetUser(username, password);
            if (user == null)
            {
                TempData["error"] = "Incorrect User Name or Password";
                return View();
            }

            FormsAuthentication.SetAuthCookie(user.UserName, true);
            return RedirectToAction("Secret");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Rocky-P/Login-Hacker-News
 static void Main(string[] args)
 {
     string ConnectionString = @"Data Source=.\sqlexpress;Initial Catalog=Hacker;Integrated Security=True";
     Console.WriteLine("Hello manager. This insures the safety of your program. Only authorized individuals have access to add another emplyee to the system");
     Console.WriteLine();
     Console.WriteLine("Please enter the individuals user name : ");
     Console.WriteLine("(Press enter to submit)");
     Console.ReadKey(true);
     string username = Console.ReadLine();
     Console.WriteLine("Please enter the individuals password");
     string password = Console.ReadLine();
     var mgr = new UserManager(ConnectionString);
     mgr.AddUser(username, password);
     Console.WriteLine("Your new user " + username + " has been created");
     Console.ReadKey(true);
 }
コード例 #4
0
        public ActionResult Secret()
        {
            ViewModel vm = new ViewModel();
            UserManager um = new UserManager(ConnectionString);
            LinkManager lm = new LinkManager(ConnectionString);

            string username = User.Identity.Name;
            vm.UserId = um.GetUserbyUsername(username);
            vm.LoginUsers = um.GetAllUser();
            vm.User = um.GetUserbyUsernameReturnUser(username);
            vm.Date = DateTime.Now;
            vm.Alllink = lm.GetAllLinks();
            vm.linksByUser = lm.GetLinkbyUsers(username);
            //linkToShow.Add(l);
            //vm.linkToShow = linkToShow;

            return View(vm);
        }
コード例 #5
0
 public ActionResult Users(int userId)
 {
     ViewModel vm = new ViewModel();
     LinkManager lm = new LinkManager(ConnectionString);
     UserManager um = new UserManager(ConnectionString);
     IEnumerable<Link> linkById = lm.GetLinkbyUserId(userId);
     vm.UserId = um.GetUserId(userId);
     vm.linksByUser = linkById;
     return View(vm);
 }