public async Task <IActionResult> PutComment([FromRoute] int id, [FromBody] Comment comment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != comment.CommentId) { return(BadRequest()); } _context.Entry(comment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("CategoryId, Name, Description, Color")] Category categoryModel) { if (ModelState.IsValid) { _context.Add(categoryModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(categoryModel)); }
public async Task <IActionResult> Create([Bind("Header,Summery,Content,HomeImageUrl,CategoryId,Location,IsShowMap")] Article articleModel) { if (ModelState.IsValid) { articleModel.DateCreated = DateTime.Now; _context.Add(articleModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(articleModel)); }