コード例 #1
0
        public ActionResult <IEnumerable <Participant> > GetAllParticipantsByRoomId(int roomId)
        {
            var room = RoomList.FindRoom(roomId);

            if (room is null)
            {
                return(NotFound());
            }

            return(room.Participants);
        }
コード例 #2
0
        public IActionResult ResetRoom(int id)
        {
            var room = RoomList.FindRoom(id);

            if (room is null)
            {
                return(NotFound());
            }

            room.Participants = new List <Participant>();

            return(NoContent());
        }
コード例 #3
0
        public ActionResult <Room> GetRoom(int id)
        {
            var room = RoomList.FindRoom(id);

            if (room is null)
            {
                return(NotFound());
            }

            HttpContext.Session.SetInt32(KeyRoomId, room.Id);

            return(room);
        }
コード例 #4
0
        public ActionResult <JoinRoomResultModel> JoinRoom(int roomId)
        {
            var room = RoomList.FindRoom(roomId);

            if (room is null)
            {
                return(new JoinRoomResultModel());
            }

            HttpContext.Session.SetInt32(KeyRoomId, roomId);
            Response.Cookies.Append(KeyRoomId, roomId.ToString());

            return(View("~/Views/Participant/Index.cshtml"));
        }
コード例 #5
0
        public ActionResult <Room> CreateRoom(Room room)
        {
            var historyRoom = RoomList.FindRoom(room.Id);

            if (!(historyRoom is null))
            {
                return(BadRequest());
            }

            RoomList.AddRoom(room);

            HttpContext.Session.SetInt32(KeyRoomId, room.Id);

            return(CreatedAtAction(nameof(GetRoom), new { id = room.Id }, room));
        }
コード例 #6
0
        public ActionResult <JoinRoomResultModel> JoinRoom(int roomId)
        {
            var room = RoomList.FindRoom(roomId);

            if (room is null)
            {
                return(new JoinRoomResultModel());
            }

            HttpContext.Session.SetInt32(KeyRoomId, roomId);
            Response.Cookies.Append(KeyRoomId, roomId.ToString());

            return(new JoinRoomResultModel()
            {
                ExistRoom = true
            });
        }
コード例 #7
0
        public ActionResult SubmitEstimation(int roomId, Participant participant)
        {
            var room = RoomList.FindRoom(roomId);

            if (room is null)
            {
                return(NotFound());
            }

            var participants = room.Participants;

            var historyParticipant = participants.FirstOrDefault(p => p.Name.Equals(participant.Name));

            if (historyParticipant is null)
            {
                participants.Add(participant);

                return(Ok());
            }

            historyParticipant.Estimation = participant.Estimation;

            return(Ok());
        }
コード例 #8
0
        private void InitializeProperties()
        {
            var roomId = HttpContext.Session.GetInt32("RoomId");

            _currentRoom = roomId.HasValue ? RoomList.FindRoom(roomId.Value) : null;
        }