public async Task <string> Validate(RoleGetOptions options) { try { _logger.LogInformation("Start role validating."); string result = ValidationUtilities.ValidateRoleName(options.Name); if (!string.IsNullOrEmpty(result)) { return(result); } if (!options.Id.HasValue) { var models = await _dao.Get(options); if (models.Count() > 0) { string message = "Role with same user name have been already created. Please try another."; _logger.LogInformation(message); return(message); } } _logger.LogInformation("Role successfuly validated."); return(null); } catch (Exception exception) { _logger.LogError(exception.Message); throw exception; } }