Example #1
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var article = await _articlesRepository.GetOne(id);

            _articlesRepository.Remove(article);
            await _articlesRepository.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #2
0
        public async Task <ActionResult> DeleteArticle(int id)
        {
            var article = await _articlesRepository.GetOne(id);

            if (article == null)
            {
                return(NotFound());
            }

            _articlesRepository.Remove(article);
            await _articlesRepository.SaveChanges();

            return(NoContent());
        }
        public IActionResult DeleteArticle([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!ArticleExists(id))
            {
                return(NotFound());
            }
            _articlesRepository.Remove(id);


            return(Ok());
        }