Esempio n. 1
0
        public BaseModelValidationResult Validate()
        {
            var validationResult = new BaseModelValidationResult();

            if (string.IsNullOrWhiteSpace(Name))
            {
                validationResult.Append($"Name cannot be empty");
            }
            if (string.IsNullOrWhiteSpace(Surname))
            {
                validationResult.Append($"Surname cannot be empty");
            }
            if (!(0 < GroupIndex && GroupIndex < 100))
            {
                validationResult.Append($"GroupIndex {GroupIndex} is out of range (0..100)");
            }

            if (!string.IsNullOrEmpty(Name) && !char.IsUpper(Name.FirstOrDefault()))
            {
                validationResult.Append($"Name {Name} should start from capital letter");
            }
            if (!string.IsNullOrEmpty(Surname) && !char.IsUpper(Surname.FirstOrDefault()))
            {
                validationResult.Append($"Surname {Surname} should start from capital letter");
            }

            return(validationResult);
        }
Esempio n. 2
0
        public BaseModelValidationResult Validate()
        {
            var validationResult = new BaseModelValidationResult();

            if (string.IsNullOrWhiteSpace(name))
            {
                validationResult.Append($"Name cannot be empty");
            }
            if (!string.IsNullOrEmpty(name) && !char.IsUpper(name.FirstOrDefault()))
            {
                validationResult.Append($"Name {name} should start from capital letter");
            }

            if (!(0 < price && price < 100001))
            {
                validationResult.Append($"Price {price} is out of range (1..100000)");
            }
            if (!(0 < quantity && quantity < 101))
            {
                validationResult.Append($"Quantity {quantity} is out of range (1..100)");
            }
            if (!(0 < delivery_time && delivery_time < 31))
            {
                validationResult.Append($"Delivery time {delivery_time} is out of range (1..30)");
            }

            return(validationResult);
        }
Esempio n. 3
0
        public BaseModelValidationResult Validate()
        {
            var validationResult = new BaseModelValidationResult();

            if (string.IsNullOrWhiteSpace(Name))
            {
                validationResult.Append($"Name cannot be empty");
            }
            if (!(0 < Kolvo))
            {
                validationResult.Append($"Kolvo ne mozhet byt otricatelnoe");
            }

            if (!string.IsNullOrEmpty(Name) && !char.IsUpper(Name.FirstOrDefault()))
            {
                validationResult.Append($"Name {Name} should start from capital letter");
            }
            if (!string.IsNullOrEmpty(City) && !char.IsUpper(City.FirstOrDefault()))
            {
                validationResult.Append($"City {City} should start from capital letter");
            }
            if (!string.IsNullOrEmpty(Country) && !char.IsUpper(Country.FirstOrDefault()))
            {
                validationResult.Append($"Surname {Country} should start from capital letter");
            }
            return(validationResult);
        }