public async Task <ShortenUrlResponseModel> ShortenUrlAsync(ShortenUrlRequestModel model) { var shortenedUrl = await _urlShorteningService.ShortenUrlAsync(model.Url); return(new ShortenUrlResponseModel { ShortenedUrl = shortenedUrl }); }
public ActionResult <ShortenUrlResponseModel> Post([FromForm] ShortenUrlRequestModel request) { string ShortUrl = _shorteningService.Shorten(request.LongUrl, request.BaseUrl); ShortenUrlResponseModel model = new ShortenUrlResponseModel(); model.ShortenedUrl = ShortUrl; return(model); }
public async Task <IActionResult> ShortenUrl( [FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Disallow)] ShortenUrlRequestModel model, CancellationToken cancellationToken = default) => await ExecuteRequestAsync(new ShortenUrlCommand(model.Url), cancellationToken);