Esempio n. 1
0
        public override async Task <ActionResult> HandleAsync(
            [FromRoute] DeletePhoneBookrecordRequest request,
            CancellationToken cancellationToken = default)
        {
            var record = _repository.Get(request.Id);

            if (record == null)
            {
                return(NotFound());
            }
            await _repository.DeleteAsync(request.Id, cancellationToken);

            await _unitOfWork.CommitAsync(cancellationToken);

            return(Ok());
        }
Esempio n. 2
0
        public override async Task <ActionResult <PhoneBookRecord> > HandleAsync(
            [FromRoute] UpdatePhoneBookrecordRequest request,
            CancellationToken cancellationToken = default)
        {
            var record = _repository.Get(request.Id);

            if (record == null)
            {
                return(NotFound());
            }
            _mapper.Map(request.Body, record);
            await _repository.UpdateAsync(record, request.Id, cancellationToken);

            record.UpdateTags(request.Body.TagIds);

            await _unitOfWork.CommitAsync(cancellationToken);

            return(Ok(record));
        }