public ActionResult <IEnumerable <Participant> > GetAllParticipantsByRoomId(int roomId) { var room = RoomList.FindRoom(roomId); if (room is null) { return(NotFound()); } return(room.Participants); }
public IActionResult ResetRoom(int id) { var room = RoomList.FindRoom(id); if (room is null) { return(NotFound()); } room.Participants = new List <Participant>(); return(NoContent()); }
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); }
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")); }
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)); }
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 }); }
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()); }
private void InitializeProperties() { var roomId = HttpContext.Session.GetInt32("RoomId"); _currentRoom = roomId.HasValue ? RoomList.FindRoom(roomId.Value) : null; }