Beispiel #1
0
        public ActionResult UpdateCommand(int id, CommandUpdateDto commandUpdateDto)
        {
            var commandModelFromRepo = _repositoryCommander.GetCommandById(id);

            if (commandModelFromRepo == null)
            {
                return(NotFound());
            }
            _mapper.Map(commandUpdateDto, commandModelFromRepo);
            _repositoryCommander.Update(commandModelFromRepo);
            _repositoryCommander.SaveChanges();
            return(NoContent());
        }
        public ActionResult UpdateCommand(int id, CommandUpdateDto cmd)
        {
            var result = _repository.GetCommandById(id);

            if (result == null)
            {
                return(NotFound());
            }
            _mapper.Map(cmd, result);   // That's all it take to update :D
            _repository.Update(result); // Does not doing anything just for good practises
            _repository.SaveChanges();
            return(NoContent());
        }
        public ActionResult Update(int id, CommandUpdateDto updateDto)
        {
            var command = _repo.Show(id);

            if (command is null)
            {
                return(NotFound());
            }

            _mapper.Map(updateDto, command);

            _repo.Update(command);
            _repo.SaveChanges();

            return(NoContent());
        }