Example #1
0
        public async Task <IActionResult> OnPostUpdate(int id)
        {
            try
            {
                var shortenedUrl = await _urlShortenerService.UpdateById(id, ShortenedUrl.LongUrl);

                StatusMessage = $"{shortenedUrl.ShortUrl} has been updated!";
                return(RedirectToPage());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "OnPostUpdate: Unable to find ShortenedUrl {Id}", id);
                StatusMessage = $"Error: Something went wrong updating {id}.";
                return(Page());
            }
        }