public void ItemTypeEnumHelperTests_ConvertMessageStringToEnum_PrivateTutor_Should_Pass()
        {
            // Arrange

            // Act
            var result = ItemTypeEnumHelper.ConvertMessageStringToEnum("Private Tutor");

            // Reset

            // Assert
            Assert.AreEqual(ItemTypeEnum.PrivateTutor, result);
        }
        public void ItemTypeEnumHelperTests_ConvertMessageStringToEnum_Tuition_Should_Pass()
        {
            // Arrange

            // Act
            var result = ItemTypeEnumHelper.ConvertMessageStringToEnum("Tuition");

            // Reset

            // Assert
            Assert.AreEqual(ItemTypeEnum.Tuition, result);
        }
        public void ItemTypeEnumHelperTests_ConvertMessageStringToEnum_LibraryCard_Should_Pass()
        {
            // Arrange

            // Act
            var result = ItemTypeEnumHelper.ConvertMessageStringToEnum("Library Card");

            // Reset

            // Assert
            Assert.AreEqual(ItemTypeEnum.LibraryCard, result);
        }
        public void ItemTypeEnumHelperTests_ConvertMessageStringToEnum_Notebook_Should_Pass()
        {
            // Arrange

            // Act
            var result = ItemTypeEnumHelper.ConvertMessageStringToEnum("Notebook");

            // Reset

            // Assert
            Assert.AreEqual(ItemTypeEnum.Notebook, result);
        }
        public void ItemTypeEnumHelperTests_ConvertMessageStringToEnum_IndexCards_Should_Pass()
        {
            // Arrange

            // Act
            var result = ItemTypeEnumHelper.ConvertMessageStringToEnum("Index Cards");

            // Reset

            // Assert
            Assert.AreEqual(ItemTypeEnum.IndexCards, result);
        }
        public void ItemTypeEnumHelperTests_ConvertMessageStringToEnum_GraduationCapAndRobe_Should_Pass()
        {
            // Arrange

            // Act
            var result = ItemTypeEnumHelper.ConvertMessageStringToEnum("Graduation Cap and Robe");

            // Reset

            // Assert
            Assert.AreEqual(ItemTypeEnum.GraduationCapAndRobe, result);
        }
        public void ItemTypeEnumHelperTests_ConvertMessageStringToEnum_FinancialAid_Should_Pass()
        {
            // Arrange

            // Act
            var result = ItemTypeEnumHelper.ConvertMessageStringToEnum("Financial Aid");

            // Reset

            // Assert
            Assert.AreEqual(ItemTypeEnum.FinancialAid, result);
        }
        public void ItemTypeEnumHelperTests_ConvertMessageStringToEnum_Diploma_Should_Pass()
        {
            // Arrange

            // Act
            var result = ItemTypeEnumHelper.ConvertMessageStringToEnum("Diploma");

            // Reset

            // Assert
            Assert.AreEqual(ItemTypeEnum.Diploma, result);
        }
        public void ItemTypeEnumHelperTests_ConvertMessageStringToEnum_BogusString_Should_Pass()
        {
            // Arrange

            // Act
            var result = ItemTypeEnumHelper.ConvertMessageStringToEnum("This doesn't exist");

            // Reset

            // Assert
            Assert.AreEqual(ItemTypeEnum.Unknown, result);
        }
        /// <summary>
        /// Converts from Int to String
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is int)
            {
                var myReturn = Enum.ToObject(targetType, value);
                return(((ItemTypeEnum)myReturn).ToMessage());
            }

            if (value is string)
            {
                // Convert the Message String to the Enum
                var myReturn = ItemTypeEnumHelper.ConvertMessageStringToEnum((string)value);

                return(myReturn);
            }
            return(0);
        }
        /// <summary>
        /// Converts String to Int
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is Enum)
            {
                //return (int)value;
                return(((ItemTypeEnum)value).ToMessage());
            }

            if (value is string)
            {
                // Convert String Enum and then Enum to Message
                var myEnum   = ItemTypeEnumHelper.ConvertMessageStringToEnum((string)value);
                var myReturn = myEnum.ToMessage();

                return(myReturn);
            }

            return(0);
        }
        /// <summary>
        /// Save by calling for Create
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void Save_Clicked(object sender, EventArgs e)
        {
            // if the name or description are not entered, the page remains on the create screen
            if (string.IsNullOrEmpty(ViewModel.Data.Name) || string.IsNullOrEmpty(ViewModel.Data.Description))
            {
                await Navigation.PushModalAsync(new NavigationPage(new ItemUpdatePage(ViewModel)));

                await Navigation.PopModalAsync();
            }
            // otherwise it creates and saves the new item
            else
            {
                var itemType     = ItemTypePicker.SelectedItem.ToString();
                var itemTypeEnum = ItemTypeEnumHelper.ConvertMessageStringToEnum(itemType);
                ViewModel.Data.ItemType = itemTypeEnum;
                ViewModel.Data.Damage   = ItemTypeEnumHelper.GetDamageFromItemType(itemTypeEnum);
                ViewModel.Data.ImageURI = ItemTypeEnumHelper.GetImageURIFromItemType(itemTypeEnum);
                ViewModel.Data.Location = ItemTypeEnumHelper.GetLocationFromItemType(itemTypeEnum);

                MessagingCenter.Send(this, "Create", ViewModel.Data);
                await Navigation.PopModalAsync();
            }
        }