Beispiel #1
0
        public async Task <ActionResult> Update([FromRoute] int id, [FromBody] MotherboardUpdateDto motherboard)
        {
            _logger.LogForModelUpdate(HttpContext, id);

            var result = await _motherboardsService.UpdateMotherboardAsync(id, motherboard);

            return(result ? Json(motherboard) : ResponseResultsHelper.UpdateError());
        }
        /// <inheritdoc/>
        public async Task <bool> UpdateMotherboardAsync(int id, MotherboardUpdateDto motherboard)
        {
            var dataBaseEntity = await _unitOfWorkHardwareAPI.MotherboardsRepository.GetByIdAsync(id);

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

            _mapper.Map(motherboard, dataBaseEntity);
            var result = await _unitOfWorkHardwareAPI.MotherboardsRepository.UpdateAsync(dataBaseEntity);

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

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