Esempio n. 1
0
        public async Task <IActionResult> Get()
        {
            var urls = await UrlStore.ListUrlsAsync();

            var publicUrls = urls.Select(url => PublicUrlVersion0.FromInternal(url));

            return(Ok(new ApiOkResponse(publicUrls)));
        }
Esempio n. 2
0
        public async Task <IActionResult> Get(string id)
        {
            StoredUrl stored;

            try
            {
                stored = await UrlStore.GetUrlByIdAsync(id);
            }
            catch (ArgumentException ex)
            {
                return(new ObjectResult(new ApiResponse(404, $"Url with id: {id} not found")));
            }

            return(Ok(new ApiOkResponse(PublicUrlVersion0.FromInternal(stored))));
        }
Esempio n. 3
0
        public async Task <IActionResult> Post([FromBody] PublicUrlVersion0 value)
        {
            var stored = await UrlStore.PostUrlAsync(value.Value);

            return(Ok(new ApiOkResponse(PublicUrlVersion0.FromInternal(stored))));
        }