コード例 #1
0
        /// <summary>
        /// update a play area
        /// </summary>
        /// <param name="tournamentId"></param>
        /// <param name="playAreaId"></param>
        /// <param name="playArea"></param>
        /// <returns></returns>
        public IActionResult UpdatePlayArea(int tournamentId, int playAreaId, Models.PlayArea playArea)
        {
            DbModels.Tournament tournament = this._repoWrapper.Tournament.GetById(tournamentId);
            if (tournament == null)
            {
                return(new NotFoundResult());
            }

            // Only update while tournament not started
            if (tournament.State != DbModels.TournamentState.Created)
            {
                return(new BadRequestObjectResult("Tournament allready started of finished"));
            }

            DbModels.PlayArea dbPlayArea = this._repoWrapper.PlayArea.GetById(playAreaId);
            if (dbPlayArea == null)
            {
                return(new NotFoundResult());
            }

            dbPlayArea.Name        = playArea.Name;
            dbPlayArea.Description = playArea.Description;

            this._repoWrapper.PlayArea.SaveChanges();

            return(new OkResult());
        }
コード例 #2
0
        /// <summary>
        /// Add a new play area
        /// </summary>
        /// <param name="tournamentId"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public ActionResult <PlayArea> AddPlayArea(int tournamentId, string name, string description)
        {
            DbModels.Tournament tournament = this._repoWrapper.Tournament.GetById(tournamentId);
            if (tournament == null)
            {
                return(new NotFoundResult());
            }

            // Only update while tournament not started
            if (tournament.State != DbModels.TournamentState.Created)
            {
                return(new BadRequestObjectResult("Tournament allready started of finished"));
            }

            DbModels.PlayArea playarea = new DbModels.PlayArea
            {
                Tournament  = tournament,
                Description = description,
                Name        = name
            };

            this._repoWrapper.PlayArea.Create(playarea);
            this._repoWrapper.PlayArea.SaveChanges();

            return(new ActionResult <PlayArea>(new PlayArea(playarea)));
        }
コード例 #3
0
        /// <summary>
        /// Get an existing play area
        /// </summary>
        /// <param name="tournamentId"></param>
        /// <param name="playAreaId"></param>
        /// <returns></returns>
        public ActionResult <PlayArea> GetPlayArea(int tournamentId, int playAreaId)
        {
            DbModels.Tournament tournament = this._repoWrapper.Tournament.GetById(tournamentId);
            if (tournament == null)
            {
                return(new NotFoundResult());
            }

            DbModels.PlayArea playarea = this._repoWrapper.PlayArea.GetById(playAreaId);
            if (playarea == null)
            {
                return(new NotFoundResult());
            }

            return(new ActionResult <PlayArea>(new PlayArea(playarea)));
        }