Esempio n. 1
0
        public async Task <ActionResult> Update([FromRoute] int id, [FromBody] ProcessorUpdateDto processor)
        {
            _logger.LogForModelUpdate(HttpContext, id);

            var result = await _processorsService.UpdateProcessorAsync(id, processor);

            return(result ? Json(processor) : ResponseResultsHelper.UpdateError());
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public async Task <bool> UpdateProcessorAsync(int id, ProcessorUpdateDto processor)
        {
            var dataBaseEntity = await _unitOfWorkHardwareAPI.ProcessorsRepository.GetByIdAsync(id);

            if (dataBaseEntity == null)
            {
                return(false);
            }

            _mapper.Map(processor, dataBaseEntity);
            var updateResult = await _unitOfWorkHardwareAPI.ProcessorsRepository.UpdateAsync(dataBaseEntity);

            if (!updateResult)
            {
                return(false);
            }

            return(await _unitOfWorkHardwareAPI.SaveChangesAsync() > 0);
        }