Ejemplo n.º 1
0
        private static Response DeleteFavoriteResponse(DeleteFavorite deleteFavorite)
        {
            DatabaseManager database = new DatabaseManager();

            (MySqlDataReader reader, var Connection) = database.RunQuery($"DELETE FROM favorites WHERE videoid='{deleteFavorite.VideoID}' AND userid='{deleteFavorite.UserID}'");
            Acknowledge ack = new Acknowledge()
            {
                Status = "OK", Reason = "Video deleted successfully."
            };
            Response resp = new Response()
            {
                Type = ResponseType.Acknowledge, Status = "OK", Content = ack
            };

            if (reader == null)
            {
                ack.Reason = "Unable to delete video.";
                ack.Status = "FAIL";
                Connection.Close();
                return(resp);
            }
            Connection.Close();
            return(resp);
        }
Ejemplo n.º 2
0
        private async void deleteVideoButton_Click(object sender, RoutedEventArgs e)
        {
            //enclose inside success.
            ConfirmWindow confirm = new ConfirmWindow(VideoTitle);

            confirm.ShowDialog();
            if (confirm.Result && !IsFavoritesType)
            {
                DeleteVideoRequest request = new DeleteVideoRequest()
                {
                    VideoID = VideoID, CourseID = CourseID
                };
                Object result = await ConnectionManager.SendRequestAsync(request, RequestType.DeleteVideo, ResponseType.Acknowledge);

                if (result != null)
                {
                    if (((JObject)result).ToObject <Acknowledge>().Status == "OK")
                    {
                        ((WrapPanel)Parent).Children.Remove(this);
                        AppNotificationManager.PushMessage(new AppNotification()
                        {
                            Message = "Video Deleted Successfully."
                        });
                    }
                }
                else
                {
                    AppNotificationManager.PushMessage(new AppNotification()
                    {
                        Message = "Unable to delete video."
                    });
                }
            }
            else if (confirm.Result && IsFavoritesType)
            {
                DeleteFavorite request = new DeleteFavorite()
                {
                    UserID = SettingsManager.Username, VideoID = VideoID
                };
                Object result = await ConnectionManager.SendRequestAsync(request, RequestType.DeleteFavorite, ResponseType.Acknowledge);

                if (result != null)
                {
                    if (((JObject)result).ToObject <Acknowledge>().Status == "OK")
                    {
                        ((WrapPanel)Parent).Children.Remove(this);
                        AppNotificationManager.PushMessage(new AppNotification()
                        {
                            Message = "Favorite Deleted Successfully."
                        });
                    }
                }
                else
                {
                    AppNotificationManager.PushMessage(new AppNotification()
                    {
                        Message = "Unable to delete favorite."
                    });
                }
            }
        }