Esempio n. 1
0
        internal async Task <bool> IsValidDetailNameAsync(
            Label errorHandlerLabel,
            string detailName,
            bool checkNameUniqueness = true)
        {
            if (string.IsNullOrEmpty(detailName))
            {
                ShowErrorMessage(errorHandlerLabel, "Type smthng!");

                return(false);
            }

            if (detailName.Length > _maxDetailNameLength)
            {
                ShowErrorMessage(errorHandlerLabel, "Name is too long.");

                return(false);
            }

            if (checkNameUniqueness)
            {
                var isUniqueName = await _detailService.IsUniqueDetailNameAsync(detailName);

                if (!isUniqueName)
                {
                    ShowErrorMessage(errorHandlerLabel, "Not unique!");

                    return(false);
                }
            }

            return(true);
        }