Exemplo n.º 1
0
        public string Add([ModelBinder] Session session, [FromBody] string url)
        {
            Uri uriResult;

            if (!(Uri.TryCreate(url, UriKind.Absolute, out uriResult) &&
                  (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps)))
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new StringContent("URL is incorrect")
                });
            }
            return(linksRepository.Create(url, session.UserId).Key);
        }
Exemplo n.º 2
0
 public IActionResult Post([FromBody] CreateLinkRequest createLink)
 {
     return(Ok(repository.Create(createLink.GetLink())));
 }
Exemplo n.º 3
0
 public IActionResult Create(Link link)
 {
     _repository.Create(link);
     return(Redirect("Index"));
 }