Beispiel #1
0
        public IHttpActionResult AddUrl([FromBody] Url url)
        {
            try
            {
                //TODO: url.LongUrl should be validates

                Url newUrl = new Url()
                {
                    LongUrl      = url.LongUrl,
                    ShortUrl     = Shortener.CreateShortUrlToken(),
                    CreationDate = DateTime.Now
                };

                Url addedUrl = urlService.Add(newUrl);
                return(this.Ok(addedUrl));
            }
            catch (Exception ex)
            {
                throw this.ThrowException(ex);
            }
        }