Example #1
0
        public DefectReadDto UpdateDefect(int id, DefectUpdateDto defect)
        {
            Defect defectToUpdate = _repository.GetDefectById(id);

            if (defectToUpdate != null)
            {
                _mapper.Map(defect, defectToUpdate);
                defectToUpdate.Modified = DateTime.Now;

                _repository.UpdateDefect(defectToUpdate);
                _repository.SaveChanges();
            }

            return(_mapper.Map <DefectReadDto>(defectToUpdate));
        }
Example #2
0
        public IActionResult UpdateDefect(int id, DefectUpdateDto defect)
        {
            if (defect == null)
            {
                return(BadRequest());
            }

            var defectModelFromRepository = _defectService.UpdateDefect(id, defect);

            if (defectModelFromRepository == null)
            {
                return(NotFound()); // 404
            }
            return(CreatedAtRoute(nameof(GetDefectById), new { id = defectModelFromRepository.Id }, defectModelFromRepository));
        }