예제 #1
0
        private async void ExecuteNavigatedTo(NavigateTo obj)
        {
            if (obj.Name == "loaded")
            {
                Type view = (Type)obj.View;
                if (view == (typeof(ZoekVrienden)))
                {
                    //loaded
                    Loaded();
                }
            }

            if (obj.Name == "friend_accepted")
            {
                User.All user     = JsonConvert.DeserializeObject <User.All>(obj.Data.ToString());
                bool     accepted = (bool)obj.Result;
                Response response = Task.FromResult <Response>(await FriendsRepository.PostFriend(user.User.ID, MainViewVM.USER.ID, accepted)).Result;

                if (response.Success == true)
                {
                    Messenger.Default.Send <Dialog>(new Dialog()
                    {
                        Message = user.User.ToString() + " is toegevoegd",
                        ViewOk  = typeof(ZoekVrienden)
                    });

                    Libraries.Socket socketSend = new Libraries.Socket()
                    {
                        To = user.User.ID, From = MainViewVM.USER.ID, Status = true
                    };

                    MainViewVM.socket.Emit("friend_ADDED:send", JsonConvert.SerializeObject(socketSend));
                }
                else
                {
                    //iets misgelopen
                }
            }
        }