//To save the artwork if there is an artist, title and an imagepath included
        private async void SaveArtwork_Click(object sender, RoutedEventArgs e)
        {
            if ((ArtArtist.Text != "") && (ArtName.Text != "") && (_imagePath != null))
            {
                _artwork = new Artwork(ArtArtist.Text, ArtName.Text);
                _artwork.ImagePath = _imagePath;
                _artwork.Description = ArtDescription.Text;
                _artwork.Room = ArtRoom.Text;
                _artwork.Signed = CheckBoxSigned.IsChecked;
                _artwork.Place = ArtPlace.Text;
                if (ArtPlace.Text == "")
                {
                    _artwork.Place = "Obestämd";
                }
                int height;
                int width;
                int.TryParse(ArtHeight.Text, out height);
                int.TryParse(ArtWidth.Text, out width);
                _artwork.Height = height;
                _artwork.Width = width;

                await _artworkLogic.SaveArtworkAsync(_artwork);

                var main = new MainWindow();
                this.Close();
                main.Show();
            }
            else
            {
                MessageBox.Show("Du måste ange tavlans titel, konstnär och bifoga bild.", "Varning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        //Button to redirect user to Main Window.
        private void BtnBack_Click(object sender, RoutedEventArgs e)
        {
            var mainWindow = new MainWindow();
            this.Close();
            mainWindow.Show();

        }
        //Save the artwork & opens Main Window.
        private async void SaveArtwork_Click(object sender, RoutedEventArgs e)
        {
            if ((ArtArtist.Text != "") && (ArtName.Text != ""))
            {
                int height;
                int width;
                int.TryParse(ArtHeight.Text, out height);
                int.TryParse(ArtWidth.Text, out width);

                await _artworkLogic.ReplaceArtwork(ArtArtist.Text, ArtName.Text, _imagePath, ArtPlace.Text, ArtDescription.Text, _artworkName, ArtRoom.Text, width, height, CheckBoxSigned.IsChecked);

                var main = new MainWindow();
                this.Close();
                main.Show();
            }
            else
            {
                MessageBox.Show("Du måste ange namn på konstnär och titel.", "Statusmeddelande", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        //Function to get the image.
        private void GetPicture()
        {
            if (_artworkLogic.GetArtworksAsync().Result[_id].ImagePath != null)
            {
                var uri = new Uri(_artworkLogic.GetArtworksAsync().Result[_id].Blob, UriKind.RelativeOrAbsolute);
                try
                {
                    ImgSlideShow.Source = new BitmapImage(uri);

                }
                catch (Exception)
                {
                    MessageBox.Show("Bilderna kan inte laddas.", "Felmeddelande", MessageBoxButton.OK, MessageBoxImage.Error);
                    var main = new MainWindow();
                    this.Close();
                    main.Show();
                }
            }
        }
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Vill du ta bort detta konstverk?", "Varning", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
            {

            }
            else
            {
                _artworkLogic.DeleteArtworkAsync(_artworkName);
                var mainWindow = new MainWindow();
                this.Close();
                mainWindow.Show();
            }
        }