public ActionResult <ValueDto> PartiallyUpdate(int id, [FromBody] JsonPatchDocument <ValueUpdateDto> patchDoc)
        {
            if (patchDoc == null)
            {
                return(BadRequest());
            }

            Value existingEntity = _valueRepository.GetSingle(id);

            if (existingEntity == null)
            {
                return(NotFound());
            }

            ValueUpdateDto valueUpdateDto = Mapper.Map <ValueUpdateDto>(existingEntity);

            patchDoc.ApplyTo(valueUpdateDto, ModelState);

            TryValidateModel(valueUpdateDto);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Mapper.Map(valueUpdateDto, existingEntity);
            Value updated = _valueRepository.Update(id, existingEntity);

            if (!_valueRepository.Save())
            {
                throw new Exception("Updating an item failed on save.");
            }

            return(Ok(Mapper.Map <ValueDto>(updated)));
        }
        public async Task <ValueModel?> Update(ValueModel model)
        {
            var value = await _repository.Update(model);

            _logger.LogDebug("Updated value {@value}", value);
            return(value);
        }
示例#3
0
        public override async Task HandleAsync(CallbackQueryUpdateMessage message)
        {
            if (!long.TryParse(Parameter, out long valueId))
            {
                throw new ArgumentException($"Can't perfom DelValue command, id parameter is not a number - {Parameter}");
            }

            var value = _valueRepository.GetById(valueId)
                        ?? throw new ArgumentException($"Can't perfom DelValue command, there is no value with id {valueId}");

            value.SetDeleted();
            _valueRepository.Update(value);

            await _botClient.SendTextMessageAsync(message, MessageCode.Done);
        }
示例#4
0
        public ValueDto Update(int id, ValueDto value)
        {
            if (id < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (value == null)
            {
                throw new ArgumentNullException();
            }

            var entity = _mapper.Map <ValueDto, Value>(value);

            value = _mapper.Map <Value, ValueDto>(_valueRepository.Update(id, entity));
            return(value);
        }
示例#5
0
        public async Task <IActionResult> Put(int id, [FromBody] UpdateValueResource updateValueResource)
        {
            var value = await _valueRepository.GetValue(id);

            if (value == null)
            {
                return(NotFound());
            }

            _mapper.Map <UpdateValueResource, Value>(updateValueResource, value);

            _valueRepository.Update(value);
            await _unitOfWork.CompleteAsync();

            return(NoContent());
        }
示例#6
0
 public async Task <Value> Update(Guid valueId, [FromBody] ValueInput value)
 {
     return(await repo.Update(valueId, value));
 }
示例#7
0
 public async Task <Value> Update(Guid crazyKey, [FromBody] ValueInput value)
 {
     return(await repo.Update(crazyKey, value));
 }