Beispiel #1
0
        public ActionResult <ApiResultBaseModel> Edit(
            [FromForm] long nBoardId
            , [FromForm] string sTitle
            , [FromForm] short nShowCount
            , [FromForm] BoardStateType typeBoardState
            , [FromForm] BoardFacultyType typeBoardFaculty
            , [FromForm] BoardAuthorityType nAuthorityDefault
            , [FromForm] string sMemo)
        {
            ApiResultReady armResult = new ApiResultReady(this);

            //유저 정보 추출
            ClaimModel cm = new ClaimModel(((ClaimsIdentity)User.Identity).Claims);
            //이 유저가 해당 관리 등급이 있는지 확인한다.
            ManagementClassCheckType typePC
                = GlobalStatic.MgtA.MgtClassCheck(cm.id_int
                                                  , ManagementClassType.Admin);

            if (typePC == ManagementClassCheckType.Ok)
            {
                using (SpaNetCoreFoundationContext db1 = new SpaNetCoreFoundationContext())
                {
                    Board findBoard
                        = db1.Board
                          .Where(m => m.idBoard == nBoardId)
                          .FirstOrDefault();

                    if (null != findBoard)
                    {
                        findBoard.Title            = sTitle;
                        findBoard.ShowCount        = nShowCount;
                        findBoard.BoardState       = typeBoardState;
                        findBoard.BoardFaculty     = (BoardFacultyType)typeBoardFaculty;
                        findBoard.AuthorityDefault = (BoardAuthorityType)nAuthorityDefault;
                        findBoard.Memo             = sMemo;

                        db1.SaveChanges();

                        //게시판 정보 json으로 저장
                        GlobalStatic.FileProc.WWW_Json_BoardInfo();
                    }
                    else
                    {
                        armResult.InfoCode = typePC.ToString();
                        armResult.Message  = "대상이 없습니다.";
                    }
                }//end using db1
            }
            else
            {
                //에러
                armResult.InfoCode = ApiResultType.PermissionCheckError.ToString();
                armResult.Message  = "권한이 없습니다.";
            }

            return(armResult.ToResult());
        }
Beispiel #2
0
        //On Create
        public BoardStateController(Board board, TetrominoManager tetrominoManager, BoardStateType initStateType)
        {
            //Fill up the dictionary by creating and adding all board states
            boardStates = new Dictionary <BoardStateType, BoardState>();
            boardStates.Add(BoardStateType.InitState, new InitBoardState(board, this));
            boardStates.Add(BoardStateType.AutoFallState, new AutoFallBoardState(board, this, tetrominoManager));
            boardStates.Add(BoardStateType.LockingState, new LockingBoardState(board, this));
            boardStates.Add(BoardStateType.LineCompletionState, new LineCompletionBoardState(board, this));
            boardStates.Add(BoardStateType.GameOverState, new GameOverBoardState(board, this));

            InitializeBoardState(initStateType);
        }
Beispiel #3
0
        public ActionResult <ApiResultBaseModel> Create(
            [FromForm] string sTitle
            , [FromForm] BoardStateType typeBoardState
            , [FromForm] BoardAuthorityType nAuthorityDefault
            , [FromForm] string sMemo)
        {
            ApiResultReady rrResult = new ApiResultReady(this);


            DateTime dtNow = DateTime.Now;

            //유저 정보 추출
            ClaimModel cm = new ClaimModel(((ClaimsIdentity)User.Identity).Claims);
            //이 유저가 해당 관리 등급이 있는지 확인한다.
            ManagementClassCheckType typePC
                = GlobalStatic.MgtA.MgtClassCheck(cm.id_int
                                                  , ManagementClassType.Admin);

            if (typePC == ManagementClassCheckType.Ok)
            {
                using (SpaNetCoreFoundationContext db1 = new SpaNetCoreFoundationContext())
                {
                    Board newBoard = new Board();
                    newBoard.Title            = sTitle;
                    newBoard.BoardState       = typeBoardState;
                    newBoard.AuthorityDefault = (BoardAuthorityType)nAuthorityDefault;

                    //기능 설정
                    newBoard.BoardFaculty |= BoardFacultyType.ShowCount_Server;

                    newBoard.ShowCount  = 10;
                    newBoard.Memo       = sMemo;
                    newBoard.CreateDate = dtNow;

                    db1.Board.Add(newBoard);
                    db1.SaveChanges();


                    //게시판 정보 json으로 저장
                    GlobalStatic.FileProc.WWW_Json_BoardInfo();
                }//end using db1
            }
            else
            {
                //에러
                rrResult.InfoCode = ApiResultType.PermissionCheckError.ToString();
                rrResult.Message  = "권한이 없습니다.";
            }

            return(rrResult.ToResult());
        }
Beispiel #4
0
        /// <summary>
        /// Assigns a start state to the board
        /// </summary>
        /// <param name="initStateType">The start state of the board</param>
        public void InitializeBoardState(BoardStateType initStateType)
        {
            BoardState initState;

            if (boardStates.TryGetValue(initStateType, out initState))
            {
                currentState = initState;

                LogState("Entry");
                currentState.Entry();
            }

            else
            {
                Debug.LogError(initStateType + " is not a valid board state type");
            }
        }
Beispiel #5
0
        /// <summary>
        /// Change from current state to new state
        /// </summary>
        /// <param name="newStateType">New state to transition to</param>
        public void ChangeState(BoardStateType newStateType)
        {
            BoardState newState;

            if (currentStateType == newStateType)
            {
                return;
            }

            if (boardStates.TryGetValue(newStateType, out newState))
            {
                //check null for initialization
                if (currentState != null)
                {
                    LogState("Exit");

                    //Exit the current state
                    currentState.Exit();
                }


                //Make current state as previous
                previousState     = currentState;
                previousStateType = currentStateType;

                //Make the new state as current
                currentState     = newState;
                currentStateType = newStateType;

                LogState("Entry");

                //Enter the new state
                currentState.Entry();
            }

            else
            {
                DebugUtils.LogError(this, newStateType + " is not a valid board state type");
            }
        }
Beispiel #6
0
        public void SetBoardState()
        {
            if (FirstCard == null)
            {
                BoardState = BoardStateType.Preflop;
            }

            if (FirstCard != null)
            {
                BoardState = BoardStateType.Flop;
            }

            if (FourthCard != null)
            {
                BoardState = BoardStateType.Turn;
            }

            if (FifthCard != null)
            {
                BoardState = BoardStateType.River;
            }
        }