public IActionResult Add(int userId, LinkToAddDto linkToAddDto) { var u = Convert.ToInt32(_userManager.GetUserId(HttpContext.User)); if (u != userId) { return(Redirect("http://localhost:52690/login")); } var result = Mapper.Map <Link>(linkToAddDto); _linkLibraryRepository.AddLink(userId, result); _linkLibraryRepository.Save(); var toReturn = Mapper.Map <LinkToAddDto>(result); return(Redirect("http://localhost:52690/links/" + userId)); }
public IActionResult UpdateLink(int userId, int linkId, LinkToAddDto linkPatchDocument) { var u = Convert.ToInt32(_userManager.GetUserId(HttpContext.User)); if (u != userId) { return(Redirect("http://localhost:52690/login")); } var link = _linkLibraryRepository.GetLink(userId, linkId); if (link == null) { return(NotFound()); } link.Address = linkPatchDocument.Address; if (!_linkLibraryRepository.Save()) { return(StatusCode(500, "A problem happened while handling your request.")); } return(Redirect("http://localhost:52690/links/" + userId)); }