Пример #1
0
        public async Task <Redirectable> LoadAsync(string key)
        {
            var storage = _storageFactory.CreateStorage <MicroUrlEntity>();
            var loaded  = await storage.LoadAsync(_keyFactory.CreateFromString(key));

            if (loaded == null)
            {
                return(null);
            }

            switch (loaded.Type)
            {
            case MicroUrlEntity.TextType:
                return(_mapper.Map <MicroText>(loaded));

            case MicroUrlEntity.UrlType:
                return(_mapper.Map <MicroUrl>(loaded));

            default:
                throw new ArgumentException("Invalid entity type");
            }
        }
        private async Task <bool> ExistsAsync(string key)
        {
            var storage = _storageFactory.CreateStorage <MicroUrlEntity>();

            return(await storage.ExistsAsync(_keyFactory.CreateFromString(key)));
        }