コード例 #1
0
 public void CreatePlayer(PlayerModel player)
 {
     if (Players.Count == 0)
     {
         //player.PlayersGrid.IsEnabled = true;
         player.IsWaiting = false;
         Players.Add(player);
     }
     else
     {
         //player.PlayersGrid.IsEnabled = false;
         player.IsWaiting = true;
         Players.Add(player);
     }
 }
コード例 #2
0
        // Подключение нового пользователя
        public void Connect(string userName)
        {
            var id = Context.ConnectionId;

            if (!Users.Any(x => x.connectionID == id))
            {
                var p = new PlayerModel { connectionID = id, Login = userName };
                Users.Add(p);

                // Посылаем сообщение текущему пользователю
                Clients.Caller.onConnected(id, userName, Users);

                // Посылаем сообщение всем пользователям, кроме текущего
                Clients.AllExcept(id).onNewUserConnected(id, userName);
            }
        }
コード例 #3
0
 public ActionResult Create(PlayerModel pl)
 {
     try
     {
         // TODO: Add insert logic here
         var player = new PlayerModel();
         player.Login = pl.Login;
         context.Players.Add(player);
         context.SaveChanges();
         return RedirectToAction("Info");
     }
     catch
     {
         return View();
     }
 }
コード例 #4
0
 public ActionResult Create(string name, int? id)
 {
     try
     {
         // TODO: Add insert logic here
         var player = new PlayerModel();
         player.Login = name;
         player.ID = id.Value;
         players.Add(player);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
コード例 #5
0
 public ActionResult EditDetailes(PlayerModel player)
 {
     context.Entry(player).State = EntityState.Modified;
     context.SaveChanges();
     return View(player);
 }