예제 #1
0
        public async Task <ActionResult> Update([FromRoute] int id, [FromBody] ProducerUpdateDto producer)
        {
            _logger.LogForModelUpdate(HttpContext, id);

            var result = await _producersService.UpdateProducerAsync(id, producer);

            return(result ? Json(producer) : ResponseResultsHelper.UpdateError());
        }
예제 #2
0
        /// <inheritdoc/>
        public async Task <bool> UpdateProducerAsync(int id, ProducerUpdateDto producer)
        {
            var dataBaseEntity = await _unitOfWorkHardwareAPI.ProducersRepository.GetByIdAsync(id);

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

            _mapper.Map(producer, dataBaseEntity);
            await _unitOfWorkHardwareAPI.ProducersRepository.UpdateAsync(dataBaseEntity);

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