コード例 #1
0
        public async Task<ActionResult> Register(string url)
        {
            var svc = new ShortUrlService();
            var shortUrl = svc.RegisterUrl(url);

            return PartialView(shortUrl);
        }
コード例 #2
0
        // POST api/Shortner
        public ShortUrl Post([FromBody]PostShortUrlRequest model)
        {
            if (model == null || model.Url.IsNullOrWhiteSpace())
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var svc = new ShortUrlService();
            var shortUrl = svc.RegisterUrl(model.Url);

            return shortUrl;
        }