Esempio n. 1
0
        public async Task <string> Validate(DepartmentGetOptions options)
        {
            try
            {
                _logger.LogInformation("Start department validating.");

                string result = ValidationUtilities.ValidateDepartmentFullName(options.FullName);
                if (!string.IsNullOrEmpty(result))
                {
                    return(result);
                }

                var models = await _dao.Get(options);

                if (models.Count() > 0)
                {
                    string message = "Department with same name have been already created. Please try another.";
                    _logger.LogInformation(message);
                    return(message);
                }

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