public async Task <string> Validate(Delivery model)
        {
            try
            {
                _logger.LogInformation("Start delivery validating.");
                StringBuilder builder = new StringBuilder();

                if (!ValidationUtilities.NotEmptyRule(model.Name))
                {
                    builder.AppendLine("Delivery name should not be empty.");
                }
                if (!ValidationUtilities.OnlyLettersNumbersAndUnderscorcesRule(model.Name))
                {
                    builder.AppendLine("Delivery name should contains only letters, dots, commas and number.");
                }
                if (!ValidationUtilities.MoreThanValueLengthRule(model.Name, 5))
                {
                    builder.AppendLine("Delivery name should be longer than 5 symbols.");
                }
                if (!ValidationUtilities.MoreThanValueRule(model.DeliveryPrice, 0))
                {
                    builder.AppendLine("Delivery price should be greater than zero.");
                }

                var models = await _dao.Get(new DeliveryGetOptions
                {
                    Name       = model.Name,
                    ExcludeIds = new List <int> {
                        model.Id
                    }
                });

                if (models.Count() > 0)
                {
                    builder.AppendLine("Delivery with same name have been already created. Please try another name.");
                }

                string message = builder.ToString();
                if (!string.IsNullOrEmpty(message))
                {
                    return(message);
                }

                _logger.LogInformation("Delivery successfuly validated.");
                return(null);
            }
            catch (Exception exception)
            {
                _logger.LogError(exception.Message);
                throw exception;
            }
        }
        private string ValidateEmail(string email)
        {
            if (!ValidationUtilities.NotEmptyRule(email))
            {
                return("Email should not be empty");
            }

            if (!ValidationUtilities.CheckEmailFormat(email))
            {
                return("Email is not valid");
            }

            return(string.Empty);
        }
        private string ValidatePassword(string password)
        {
            if (!ValidationUtilities.NotEmptyRule(password))
            {
                return("Password should not be empty.");
            }

            int minLength = 6;

            if (!ValidationUtilities.MoreThanValueLengthRule(password, minLength))
            {
                return($"Password length should be more than {minLength}.");
            }

            return(string.Empty);
        }
        private string ValidateUserName(string userName)
        {
            if (!ValidationUtilities.NotEmptyRule(userName))
            {
                return("User name should not be empty.");
            }

            int minLength = 5;

            if (!ValidationUtilities.MoreThanValueLengthRule(userName, minLength))
            {
                return($"User name length length should be more than {minLength}.");
            }
            ;

            if (!ValidationUtilities.OnlyLettersNumbersAndUnderscorcesRule(userName))
            {
                return("User name must contains only letters, numbers and underscores.");
            }

            return(string.Empty);
        }
        public string Validate(Order model)
        {
            try
            {
                _logger.LogInformation("Start order validating.");
                StringBuilder builder = new StringBuilder();

                if (!ValidationUtilities.NotEmptyRule(model.Addres))
                {
                    builder.AppendLine("Your address should not be empty.");
                }
                if (!ValidationUtilities.NotEmptyRule(model.FullName))
                {
                    builder.AppendLine("Your full name should not be empty.");
                }
                if (!ValidationUtilities.OnlyLettersNumbersAndUnderscorcesRule(model.FullName))
                {
                    builder.AppendLine("Your full name should contains only letters, dots, commas and number.");
                }
                if (!ValidationUtilities.NotNullRule(model.DeliveryId))
                {
                    builder.AppendLine("You must choose a delivery service.");
                }

                string message = builder.ToString();
                if (!string.IsNullOrEmpty(message))
                {
                    return(message);
                }

                _logger.LogInformation("Order successfuly validated.");
                return(null);
            }
            catch (Exception exception)
            {
                _logger.LogError(exception.Message);
                throw exception;
            }
        }