public IActionResult Post([FromBody] CreateLinkRequest createLink) { if (!ModelState.IsValid) { return(BadRequest(@"Link url format is not correct. Use full link started from http:// or https://")); } _repository.AddLink(createLink.GetLink()); return(Ok()); }
public IActionResult Post([FromBody] CreateLinkRequest createLink) { if (!ModelState.IsValid) { return(BadRequest(@"Не верный формат ссылки, используйте http:// или https://")); } _repository.AddLink(createLink.GetLink()); return(Ok()); }
public IActionResult Create(Link link) { if (!ModelState.IsValid) { TempData["msg"] = "<script>alert('Link url format is not correct. Use full link started from http:// or https://');</script>"; return(Redirect("Index")); } _repository.AddLink(link); return(Redirect("Index")); }
public IActionResult Create(Link link) { if (!ModelState.IsValid) { TempData["msg"] = "<script>alert('Ссылка имеет не корректный вид, используйте http:// или https://');</script>"; return(Redirect("Index")); } _repository.AddLink(link); return(Redirect("Index")); }
public async Task <ActionResult <Link> > CreateLink(LinkToCreateDto link) { if (link == null) { throw new ArgumentNullException(nameof(link)); } var linkEntity = _mapper.Map <Link>(link); _repo.AddLink(linkEntity); await _repo.SaveChangesAsync(); var linkToReturn = _mapper.Map <LinkDto>(linkEntity); return(CreatedAtAction( "GetLink", new { id = linkToReturn.Id }, linkToReturn)); }
public IActionResult Create(Link link) { _repository.AddLink(link); return(Redirect("Index")); }
public async Task CreateLink(Link link) { await _linksRepository.AddLink(link); }