예제 #1
0
        private Alias GetAlias <T>(string aliasName, out T result) where T : ServiceResultBase, new()
        {
            result = new T();
            Alias alias = null;

            ShortUrl shortUrl = shortUrlRepository.GetByAliasName(aliasName);

            result = Validation.Validate <T>(() => shortUrl == null, "alias", TextMessages.UrlWithTheSpecifiedAliasDoesNotExist.FormatWith(aliasName)).Result();

            if (result.RuleViolations.IsEmpty())
            {
                // TODO: Consider casing
                alias = shortUrl.Aliases.Single(a => a.Name.Equals(aliasName, StringComparison.OrdinalIgnoreCase));
            }

            return(alias);
        }