public async Task <IActionResult> PutEmployee(int id, [FromBody] Employee employee) { if (id != employee.Id) { return(BadRequest()); } _context.Entry(employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult EditDocument(NewDocumentViewModel viewModel) { var pId = (int)TempData["id"]; Documents document = _context.Documents.SingleOrDefault(r => r.DocumentsID == pId); if (ModelState.IsValid) { document.Name = viewModel.Name; document.Author = viewModel.Author; document.Excerpt = viewModel.Excerpt; document.Format = _context.Formats.FirstOrDefault(f => f.Id == viewModel.FormatID); document.Category = _context.Categories.FirstOrDefault(c => c.Id == viewModel.CategoryID); _context.Entry(document).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } return(RedirectToAction("AfterLogin", "Home")); }