Exemplo n.º 1
0
        /// <summary>
        /// Creator: Michael Thompson
        /// Created: 2/19/2020
        /// Approver: Austin Gee
        ///
        /// Method to validate that there is a description and a photo path and sends that data to the database
        /// </summary>
        /// <remarks>
        /// Updater: Michael Thompsom
        /// Updated: 4/28/2020
        /// Update: To book specifications
        /// Approver: Austin Gee
        /// </remarks>
        private void BtnSubmitAnimalUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (currentPetProfile.Source != null)
            {
                if (String.IsNullOrEmpty(txtAnimalProfileDescription.Text))
                {
                    MessageBox.Show("Please enter the animal's profile description");
                    return;
                }

                var    selectedItem = dgAnimalProfiles.SelectedItem;
                string ID           = (dgAnimalProfiles.SelectedCells[0].Column.GetCellContent(selectedItem) as TextBlock).Text;
                try
                {
                    int animalID = Int32.Parse(ID);

                    string profileDescription   = txtAnimalProfileDescription.Text;
                    byte[] profileImage         = imgToByteArray(currentPetProfile.Source as BitmapImage);
                    string profileImageMimeType = "jpg";
                    _animalManager.UpdatePetProfile(animalID, profileDescription, profileImage, profileImageMimeType);
                    WPFErrorHandler.SuccessMessage("Animal Successfully Updated");
                    ClearDisplay();
                }
                catch (Exception ex)
                {
                    WPFErrorHandler.ErrorMessage(ex.Message + "\n\n" + ex.InnerException.Message);
                    ClearDisplay();
                }
                currentPetProfile.Source = new BitmapImage();
                lblAnimalBreed.Content   = "";
                lblAnimalName.Content    = "";
                txtAnimalProfileDescription.Clear();
                lblAnimalSpecies.Content = "";
            }
            else
            {
                WPFErrorHandler.ErrorMessage("Please supply an Image");
            }
        }