コード例 #1
0
        public async Task <ActionResult> UpdateCommand(int id, CommandUpdateDTO cmdUpdateDTO)
        {
            var commandToUpdate = await _db.GetCommandByIdAsync(id);

            if (commandToUpdate == null)
            {
                return(NotFound());
            }

            //takes care of updating- hence empty interface implementation
            _mapper.Map(cmdUpdateDTO, commandToUpdate);

            //just in case later in future you need more specific update implementation
            await _db.UpdateCommandAsync(commandToUpdate);

            await _db.SaveChangesAsync();

            return(NoContent());
        }