public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Department,VisitorCount")] StaffNamesDTO staffNamesDTO) { if (id != staffNamesDTO.Id) { return(NotFound()); } var staffNames = new StaffNames() { Id = staffNamesDTO.Id, Name = staffNamesDTO.Name, Department = staffNamesDTO.Department, VisitorCount = staffNamesDTO.VisitorCount }; if (ModelState.IsValid) { try { _context.Update(staffNames); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StaffNamesExists(staffNames.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(staffNames)); }
public IActionResult Create([Bind("Id,Name,Department,VisitorCount")] StaffNamesDTO staffNamesDTO) { var staffNames = new StaffNames() { Id = staffNamesDTO.Id, Name = staffNamesDTO.Name, Department = staffNamesDTO.Department, VisitorCount = staffNamesDTO.VisitorCount }; if (ModelState.IsValid) { _context.Add(staffNames); _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(staffNamesDTO)); }