private async void MakeChatroom(int bobs_ID) { Response res = Task.FromResult <Response>(await ChatRoomRepository.PostChatRoom(bobs_ID)).Result; if (res.Success == true) { VindRitChatVM.ID = res.NewID.Value; Bob.All bob = VindRitVM.SelectedBob; Libraries.Socket socketSendToBob = new Libraries.Socket() { From = MainViewVM.USER.ID, //from user To = bob.User.ID, //to bob Status = true, Object = res.NewID.Value }; Libraries.Socket socketSendToUser = new Libraries.Socket() { From = bob.User.ID, //from bob To = MainViewVM.USER.ID, //to user Status = true, Object = res.NewID.Value }; MainViewVM.socket.Emit("chatroom_OPEN:send", JsonConvert.SerializeObject(socketSendToBob)); //bob MainViewVM.socket.Emit("chatroom_OPEN:send", JsonConvert.SerializeObject(socketSendToUser)); //bob } }
//Methods private async Task GetCurrentTrip() { this.Loading = true; RaisePropertyChanged("Loading"); await Task.Run(async() => { Trip currenttrip = Task.FromResult <Trip>(await TripRepository.GetCurrentTrip()).Result; if (currenttrip != null) { if (currenttrip.Active == true) { Trip.All trips_all = new Trip.All(); User.All user = await UsersRepository.GetUserById(currenttrip.Users_ID); Bob.All bob = await BobsRepository.GetBobById(currenttrip.Bobs_ID); Users_Destinations destination = await DestinationRepository.GetDestinationById((currenttrip.Destinations_ID)); Party party = await PartyRepository.GetPartyById(currenttrip.Party_ID); Trip.All newTrip = new Trip.All(); newTrip.Trip = currenttrip; newTrip.Party = party; newTrip.User = user; newTrip.Bob = bob; newTrip.Destination = destination; MoveCar(newTrip.Trip.Status_Name); this.CurrentTrip = newTrip; } else { this.CurrentTrip = null; //geen current trip nu } } RaiseAll(); }); }
//by user //wanneer bob accepteer, wordt door gebruiker die aanvraagd aangemaakt private async void MakeTrip(Trip trip, int bobID) { Response res = Task.FromResult <Response>(await TripRepository.PostTrip(trip)).Result; if (res.Success == true) { VindRitVM.StatusID = 1; Location location = await LocationService.GetCurrent(); Trips_Locations tripL = new Trips_Locations() { Trips_ID = res.NewID.Value, Location = JsonConvert.SerializeObject(location), Statuses_ID = VindRitVM.StatusID }; Response okTripL = await TripRepository.PostLocation(tripL); Trip currentTrip = Task.FromResult <Trip>(await TripRepository.GetCurrentTrip()).Result; Bob.All bob = VindRitVM.SelectedBob; Libraries.Socket socketSendToBob = new Libraries.Socket() { From = MainViewVM.USER.ID, //from user To = bob.User.ID, //to bob Status = true, Object = currentTrip }; MainViewVM.socket.Emit("trip_START:send", JsonConvert.SerializeObject(socketSendToBob)); //bob StartTrip(currentTrip); //user TripSave(currentTrip); MakeChatroom(bobID); } }
private async Task <Boolean> AddComment_task() { ChatComment comment = new ChatComment() { ChatRooms_ID = MainViewVM.ChatRoom.ID, Comment = this.ChatComment }; Response res = await ChatRoomRepository.PostChatComment(comment); if (res.Success == true) { int bobID = ChatRoom.ChatRoom.Bobs_ID; Bob.All bob = Task.FromResult <Bob.All>(await BobsRepository.GetBobById(bobID)).Result; int userID = ChatRoom.ChatRoom.Users_ID; Libraries.Socket socketSendToBob; Libraries.Socket socketSendToUser; if (MainViewVM.USER.IsBob == false) { socketSendToBob = new Libraries.Socket() { From = MainViewVM.USER.ID, To = bob.User.ID, Status = true, Object = comment.Comment, Object2 = true }; socketSendToUser = new Libraries.Socket() { From = bob.User.ID, To = ChatRoom.ChatRoom.Users_ID, Status = true, Object = comment.Comment, Object2 = false }; } else { socketSendToBob = new Libraries.Socket() { From = MainViewVM.USER.ID, To = bob.User.ID, Status = true, Object = comment.Comment, Object2 = false }; socketSendToUser = new Libraries.Socket() { From = bob.User.ID, To = ChatRoom.ChatRoom.Users_ID, Status = true, Object = comment.Comment, Object2 = true }; } MainViewVM.socket.Emit("chatroom_COMMENT:send", JsonConvert.SerializeObject(socketSendToUser)); MainViewVM.socket.Emit("chatroom_COMMENT:send", JsonConvert.SerializeObject(socketSendToBob)); this.ChatComment = ""; RaiseAll(); } return(res.Success); }