Пример #1
0
        public async Task <Response <string> > Handle(DeleteItemLogicallyCommand request, CancellationToken cancellationToken)
        {
            var item = await _itemRepository.GetByIdAsync(request.Id);

            if (item == null)
            {
                throw new NotFoundException("The item was not found!");
            }

            item.Active = false;
            await _itemRepository.UpdateAsync(item);

            return(new Response <string>("Deactivate!"));
        }
Пример #2
0
        public async Task <Response <string> > Handle(UpdateItemCommand request, CancellationToken cancellationToken)
        {
            var item = await _itemRepository.GetByIdAsync(request.Key);

            if (item == null)
            {
                throw new NotFoundException("The item was not found!");
            }

            //var codeAlreadyUsed = await _itemRepository

            _mapper.Map(request, item);

            await _itemRepository.UpdateAsync(item);

            return(new Response <string>("Updated!"));
        }