Пример #1
0
        public void ReceiveBestellingGeplaatstEvent(BestellingGeplaatstEvent message)
        {
            var bestelling = Mapper.Map <Bestelling>(message.Bestelling);

            _bestellingDataMapper.Insert(bestelling);

            _betalingVerwerkenService.HandleBestellingVerwerken(bestelling.Factuurnummer);
        }
        public void ReceiveBestellingGeplaatstEvent(BestellingGeplaatstEvent message)
        {
            var bestelling = Mapper.Map <BevestigdeBestelling>(message.Bestelling);

            int index = 0;

            foreach (var bestelRegel in message.Bestelling.BestelRegels)
            {
                var artikel = _artikelDataMapper.GetById((int)bestelRegel.Artikelnummer);
                bestelling.BestelRegels[index].AfbeeldingUrl = artikel.AfbeeldingUrl;
                index++;
            }
            _bestellingDataMapper.Insert(bestelling);
        }
        public long HandlePlaatsBestelling(PlaatsBestellingCommand request)
        {
            var bestelling = MapBestelling(request.Bestelling);

            try
            {
                _bestellingDataMapper.Insert(bestelling);
                bestelling.Factuurnummer = bestelling.Id;
                _bestellingDataMapper.Update(bestelling);
            }
            catch (Exception ex)
            {
                _logger.LogError("DB exception occured with klantnummer: {0}", bestelling.Klantnummer);
                _logger.LogDebug(
                    "DB exception occured with klant {}, it threw exception: {}. Inner exception: {}",
                    bestelling, ex.Message, ex.InnerException?.Message
                    );
                throw new DatabaseException("Something unexpected happend while inserting into the database");
            }

            _eventPublish.Publish(new BestellingGeplaatstEvent(bestelling, NameConstants.BestelServiceBestellingGeplaatstEvent));
            return(bestelling.Id);
        }