public void UpdateCommand(Command command) { if (command != null) { _context.Entry(command).State = EntityState.Modified; } else { throw new ArgumentNullException(nameof(command)); } }
public async Task <IActionResult> PutCommand(int id, CommandUpdateDTO commandUpdateDTO) { //if (id != command.ID) //{ // return BadRequest(); //} var command = _context.Commands.FirstOrDefault(c => c.ID == id); if (command == null) { return(NotFound()); } _mapper.Map(commandUpdateDTO, command); _context.Entry(command).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommandExists(id)) { return(NotFound()); } else { throw; } } return(CreatedAtAction(nameof(GetCommand), new { command.ID }, command)); }