public async Task <IActionResult> PutTaskItem([FromRoute] int id, [FromBody] TaskItem taskItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != taskItem.TaskItemID) { return(BadRequest()); } _context.Entry(taskItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("UserID,UserName")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Create([Bind("CategoryID,CategoryName")] Category category) { if (ModelState.IsValid) { _context.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <T> SaveAsync(T entity) { await _context.SaveChangesAsync(); return(entity); }