Exemple #1
0
        public async Task <RespContainer <ItemResponse> > Handle(AddItemCommand request, CancellationToken cancellationToken)
        {
            Models.Item item   = _itemMapper.Map(request.Data);
            Models.Item result = _itemRespository.Add(item);

            int modifiedRecords = await _itemRespository.UnitOfWork.SaveChangesAsync();

            _logger.LogInformation(Events.Add, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords);
            _logger.LogInformation(Events.Add, Messages.ChangesApplied_id, result?.Id);

            return(RespContainer.Ok(_itemMapper.Map(result), "Item Created"));
        }
Exemple #2
0
        public async Task <ItemResponse> AddItemAsync(AddItemRequest request)
        {
            Item item   = _itemMapper.Map(request);
            Item result = _itemRespository.Add(item);

            int modifiedRecords = await _itemRespository.UnitOfWork.SaveChangesAsync();

            _logger.LogInformation(Events.Add, Messages.NumberOfRecordAffected_modifiedRecords, modifiedRecords);
            _logger.LogInformation(Events.Add, Messages.ChangesApplied_id, result?.Id);

            return(_itemMapper.Map(result));
        }