public async Task <IActionResult> PutArticle(int id, [FromForm] Article article) { if (id != article.ArticleId) { return(BadRequest()); } if (article.ArticleImageFile != null) { DeleteImage(article.ArticleImageName); article.ArticleImageName = await SaveImage(article.ArticleImageFile); } _context.Entry(article).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArticleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCategory(int id, [FromForm] Category category) { if (id != category.CategoryId) { return(BadRequest()); } if (category.CategoryImageFile != null) { DeleteImage(category.CategoryImageName); category.CategoryImageName = await SaveImage(category.CategoryImageFile); } _context.Entry(category).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }