コード例 #1
0
        static void Main(string[] args)
        {
            WebClientServiceClient client = new WebClientServiceClient();

            UserData user = new UserData()
            {
                userName = "******",
                password = "******"
            };

            Console.WriteLine($"Trying to register '{user.userName}' with pass: '******'");
            bool registerResult = client.register(user);

            Console.WriteLine($"Register result: {registerResult}\n");

            Console.WriteLine($"Trying to login with user: '******' and pass: '******'");
            bool loginResult = client.login(user);

            Console.WriteLine($"Login result: {loginResult}\n");


            Console.WriteLine("Trying to grab LeaderBoard to Console:\n");
            LeaderboardEntryData[] leaderBoard = client.GetLeaderBoard();
            for (int i = 0; i < leaderBoard.Length; i++)
            {
                Console.WriteLine($"{i + 1} Place: {leaderBoard[i].userName} - {leaderBoard[i].score} Points");
            }
            Console.WriteLine("");
            client.Close();
            Console.ReadLine();
        }
コード例 #2
0
        public ActionResult Leaderboard()
        {
            WebClientServiceClient client = new WebClientServiceClient();

            if (AccountController.UserName != null)
            {
                ViewBag.Message     = "Track your highscore, and compete with others!";
                ViewBag.leaderboard = client.GetLeaderBoard();
            }
            else
            {
                ViewBag.Message = "Your Are Not Allowed To See The LeaderBoard, Please Login First";
            }

            return(View());
        }
コード例 #3
0
        public ActionResult Login(LoginViewModel model, string returnUrl) {
            if(!ModelState.IsValid) {
                return View(model);
            }
            WebClientServiceClient client = new WebClientServiceClient();
            UserData userData = new UserData() {
                userName = model.UserName,
                password = model.Password
            };

            if(client.login(userData)) {
                UserName = userData.userName;
                return RedirectToLocal(returnUrl);
            } else {
                UserName = null;
                return View(model);
            }
        }
コード例 #4
0
 public ActionResult Register(RegisterViewModel model) {
     if(ModelState.IsValid) {
         WebClientServiceClient client = new WebClientServiceClient();
         UserData userData = new UserData() {
             userName = model.UserName,
             password = model.Password
         };
         if(client.register(userData)) {
             if(client.login(userData)) {
                 UserName = userData.userName;
                 return RedirectToAction("Index", "Home");
             } else {
                 UserName = null;
             }
         } else {
             UserName = null;
         }
     }
     // If we got this far, something failed, redisplay form
     return View(model);
 }