/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UpdateRoomResponse response = new UpdateRoomResponse(); return(response); }
public override void Execute(string packet) { UpdateRoomResponse updateRoomResponse = JsonConvert.DeserializeObject <UpdateRoomResponse>(packet); GameViewModel gvm = (ClientObject.view as GameViewModel); switch (updateRoomResponse.Type) { case UpdateRoomType.UpdatePlayers: bool isSelector = ClientObject.user.Login == updateRoomResponse.Selector.Login; Application.Current.Dispatcher.Invoke(() => { (((((MainWindow)Application.Current.MainWindow).Frame.Content as Game)?.GameFrame.Content) as CategoriesAndQuestionsTable)?.ChangeButtonEProp(isSelector); }); gvm.UpdatePoints(updateRoomResponse.Player); break; case UpdateRoomType.UpdateTable: Application.Current.Dispatcher.Invoke(() => { (((MainWindow)Application.Current.MainWindow).Frame.Content as Game).GameFrame.NavigationService.GoBack(); }); gvm.BlockAnswerButton(false); break; } }
private void NotifyPlayersAboutUpdateRoom(ClientObject client, RoomObject room, UpdateRoomType type) { var response = new UpdateRoomResponse(); if (type == UpdateRoomType.UpdatePlayers) { response.Type = UpdateRoomType.UpdatePlayers; response.Player = client.Player; response.Selector = room.Selector.Player; if (room.Respondent != null) { response.Respondent = room.Respondent.Player; } } else { response.Type = UpdateRoomType.UpdateTable; room.Game.StopAnswerButtonClickTimer(); } string packetResponse = JsonConvert.SerializeObject(response); //после отправки удаляем респондента room.Respondent = null; room.SendMessageToAllClients(packetResponse); }
public async Task <UpdateRoomResponse> UpdateRoom(UpdateRoomRequest requestModel) { //Find and check if room exists in database var room = await FindById(requestModel.RoomId); //Check if room type exists if (!await _param.IsOfParamType(requestModel.RoomType, GlobalParams.ParamTypeRoomType)) { throw new HttpStatusCodeException(HttpStatusCode.NotFound, "RoomService: RoomType is not valid"); } //Update room with new information room = UpdateRoomRequest.UpdateToRoom(room, requestModel); //Update to database room = await _repoWrapper.Room.UpdateAsync(room, room.RoomId); var equipments = (List <Equipment>) await _repoWrapper.Equipment.FindAllAsyncWithCondition(e => e.RoomId == room.RoomId); List <int> equipmentIds = null; if (EnumerableExtensions.Any(equipments)) { equipmentIds = equipments.Select(e => e.EquipmentId).ToList(); } return(UpdateRoomResponse.ResponseFromRoom(room, equipmentIds)); }
public override async Task <ActionResult <UpdateRoomResponse> > HandleAsync(UpdateRoomRequest request, CancellationToken cancellationToken) { var response = new UpdateRoomResponse(request.CorrelationId()); var toUpdate = _mapper.Map <Room>(request); await _repository.UpdateAsync(toUpdate); var dto = _mapper.Map <RoomDto>(toUpdate); response.Room = dto; return(Ok(response)); }
public void delete(UpdateRoomRequest request) { try { var response = new UpdateRoomResponse(); var bc = new RoomComponent(); bc.Update(request.Room); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UpdateRoomResponse response = new UpdateRoomResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Room", targetDepth)) { var unmarshaller = RoomUnmarshaller.Instance; response.Room = unmarshaller.Unmarshall(context); continue; } } return(response); }
public async Task <ActionResult> UpdateRoom() { //Request.Body.Position = 0; var input = await Request.GetRawBodyBytesAsync(); var request = _serializer.DeserializeAs <UpdateRoomRequest>(input); var response = new UpdateRoomResponse(); try { _gameServerApi.UpdateRoom(request.RoomId, request.Players); } catch (Exception ex) { _logger.Error($"Update room error: {ex}"); response.ResultCode = ResultCode.RequestProcessingError; } return(new FileContentResult(_serializer.Serialize(response), "text/html")); }