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); }
public IActionResult Post([FromBody] CreateLinkRequest createLink) { return(Ok(repository.Create(createLink.GetLink()))); }
public IActionResult Create(Link link) { _repository.Create(link); return(Redirect("Index")); }