コード例 #1
0
        public ActionResult ShowUsers()
        {
            UserDataHandler dataSource          = new UserDataHandler();
            ICollection <UserRegistration> data = dataSource.GetAllUsers();

            return(View(data));
        }
コード例 #2
0
        public ActionResult DeleteUserPage(FormCollection form)
        {
            int num = Convert.ToInt32(form["registerNumber"].ToString());

            if (ModelState.IsValid)
            {
                UserDataHandler datahandler         = new UserDataHandler();
                ICollection <UserRegistration> data = datahandler.GetAllUsers();
                UserRegistration reg = new UserRegistration();
                reg = data.Single(x => x.regnumber == num);
                data.Remove(reg);
                return(RedirectToAction("successPage"));
            }
            return(RedirectToAction("ErrorLogin"));
        }
コード例 #3
0
        public ActionResult UserLoginPage(UserRegistration user)
        {
            UserDataHandler dh = new UserDataHandler();
            ICollection <UserRegistration> userData = dh.GetAllUsers();

            if (ModelState.IsValid)
            {
                if (userData.Any(x => x.password == user.password) && userData.Any(x => x.name == user.name))
                {
                    //     dataHandler.AddUser(user);
                    return(RedirectToAction("successPage"));
                }
                return(RedirectToAction("ErrorLogin"));
            }
            return(RedirectToAction("ErrorLogin"));
        }