コード例 #1
0
        public ViewResult Shorten(ShortenModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }

            model.ShortenedUrl = _service.ShortenAndStore(model.Url);
            return(View(model));
        }
コード例 #2
0
        public async Task <IActionResult> ShortenAsync(
            [FromForm] ShortenModel model)
        {
            var result = await _shortenService.ShortenAsync(
                UserGuid, model.Url, model.Proposal, model.Password, model.ExpireAfter);

            if (result is null)
            {
                return(BadRequest());
            }

            return(Json(result));
        }