示例#1
0
        private bool CheckForSpecialCharacters()
        {
            var removedWhiteSpace = NewFoodEntryText.Replace(" ", "");

            return(removedWhiteSpace.Any(c => !Char.IsLetterOrDigit(c)));
        }
示例#2
0
        private async Task <bool> VerifyIfProductExistAndNoSpecialSigns()
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();
            var listOfAllProdcuts           = GetListOfAllProducts();
            var doesProductExist            = listOfAllProdcuts.Where(c => c.name.ToLower() == NewFoodEntryText.ToLower());

            if (String.IsNullOrEmpty(NewFoodEntryText))
            {
                await CoreMethods.DisplayAlert("Uwaga", "Nie wpisales nazwy produktu, sprobuj ponowownie", "OK");

                CanExecuteAddButton = true;
                return(false);
            }
            var isSpecialCharacter = CheckForSpecialCharacters();

            if (isSpecialCharacter)
            {
                await CoreMethods.DisplayAlert("Uwaga", "W nazwie sa specjalne znaki, prosze o usuniecie i sprobowanie ponownie", "OK");

                return(false);
            }
            if (doesProductExist.Count() > 0)
            {
                var alertResult = await CoreMethods.DisplayAlert("Uwaga", String.Format("Produkt o nazwie {0}, juz istnieje. Czy chcesz dodac mimo wszystko?", NewFoodEntryText), "OK", "Wroc");

                if (alertResult)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }