Example #1
0
        public IActionResult Edit(string id, [Bind("Id,Order,Url,Description,UserId")] Link link, string tags)
        {
            if (id != link.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _linksService.UpdateLink(link);
                    var existingLink = _linksService.Find(id);
                    _linksService.AssignTags(existingLink, tags);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LinkExists(link.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(link));
        }
        public async Task <IActionResult> PutLink(string id, Link link)
        {
            if (id != link.Id)
            {
                return(BadRequest());
            }

            try
            {
                _linksService.UpdateLink(link);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LinkExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }