public async Task <IActionResult> Edit(int id, [Bind("SessionId,UserId,SessionDate,SessionStatus,SessionToken")] Usersession usersession)
        {
            if (id != usersession.SessionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usersession);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsersessionExists(usersession.SessionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Endusers, "UserId", "UserEmail", usersession.UserId);
            return(View(usersession));
        }
Beispiel #2
0
 void Start()
 {
     button = gameObject.GetComponent <Button>();
     button.onClick.AddListener(() =>
     {
         Usersession.SetPlayer(player);
         SceneManager.LoadScene("SampleScene");  // 进入游戏模式
     });
 }
        public async Task <IActionResult> Create([Bind("SessionId,UserId,SessionDate,SessionStatus,SessionToken")] Usersession usersession)
        {
            if (ModelState.IsValid)
            {
                _context.Add(usersession);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.Endusers, "UserId", "UserEmail", usersession.UserId);
            return(View(usersession));
        }
Beispiel #4
0
    public async void Login()
    {
        LoadingPanel.SetActive(true);
        var info = new LoginRequest(usernameInput.text, passwordInput.text);

        Usersession.SetUser(info.username, info.password);

        var content = GameManager.ObjToHttpContent(info);
        HttpResponseMessage resp;

        try
        {
            resp = await client.PostAsync("http://127.0.0.1:9000/login", content);
        }
        catch (Exception)
        {
            LoadingPanel.SetActive(false);
            infoLabel.text = "连接服务器错误";
            return;
        }

        var result    = resp.Content.ReadAsStringAsync().Result;
        var loginResp = JsonUtility.FromJson <LoginResponse>(result);

        LoadingPanel.SetActive(false);

        ScrollContent.transform.DetachChildren(); // 清空子元素

        if (loginResp.code == 100)
        {
            LoginPanel.SetActive(false);
            prefabs = (GameObject)Resources.Load("Prefabs/PlayerInfoButton");
            foreach (var player in loginResp.players)
            {
                GameObject infoButton = GameObject.Instantiate(prefabs) as GameObject;
                var        button     = infoButton.GetComponent <PlayerInfoButton>();
                button.setText(player);
                infoButton.SetActive(true);
                infoButton.transform.SetParent(ScrollContent.transform, false);
            }
            PlayerPanel.SetActive(true);
        }
        else if (loginResp.code == 101)
        {
            infoLabel.text = "用户不存在";
        }
        else if (loginResp.code == 102)
        {
            infoLabel.text = "密码错误";
        }
        timer.Add(() => { infoLabel.text = ""; }, 2);
    }
Beispiel #5
0
 void Start()
 {
     Instance = this;
     DontDestroyOnLoad(this);
 }