public async Task <ActionResult> Update([FromRoute] int id, [FromBody] ProcessorCoreUpdateDto cpuCore)
        {
            _logger.LogForModelUpdate(HttpContext, id);

            var result = await _processorCoresService.UpdateProcessorCoreAsync(id, cpuCore);

            return(result ? Json(cpuCore) : ResponseResultsHelper.UpdateError());
        }
Beispiel #2
0
        /// <inheritdoc/>
        public async Task <bool> UpdateProcessorCoreAsync(int id, ProcessorCoreUpdateDto cpuCore)
        {
            var dataBaseEntity = await _unitOfWorkHardwareAPI.ProcessorCoresRepository.GetByIdAsync(id);

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

            _mapper.Map(cpuCore, dataBaseEntity);
            var updateResult = await _unitOfWorkHardwareAPI.ProcessorCoresRepository.UpdateAsync(dataBaseEntity);

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

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