ArmedCards.Web.Controllers.Game.Board.LeaveController.Index C# (CSharp) Метод

Index() публичный Метод

Action responsible for leaving a game
public Index ( Int32 id, Entities playerType, System.Boolean windowUnload = false ) : System.Web.Mvc.ActionResult
id System.Int32 The game id to leave
playerType Entities The type of player leaving
windowUnload System.Boolean
Результат System.Web.Mvc.ActionResult
        public ActionResult Index(Int32 id, Entities.Enums.GamePlayerType playerType, Boolean windowUnload = false)
        {
            Entities.User user = new Entities.User
            {
                UserId = Authentication.Security.CurrentUserId,
                DisplayName = Authentication.Security.CurrentUserName
            };

            if(windowUnload)
            {
                String jobId = BackgroundJob.Schedule(() => _leaveGame.Execute(id, user.UserId, user.DisplayName, playerType), TimeSpan.FromSeconds(20));

                String key = String.Format("LeaveGame_{0}_JobId", id);

                Session.Add(key, MachineKey.Protect(Encoding.ASCII.GetBytes(jobId), Session.SessionID));
            }
            else
            {
                _leaveGame.Execute(id, user, playerType);
            }

            return Redirect("/GameListing");
        }