public async Task <ActionResult <BevestigdeBestelling> > GetNextBestelling() { var email = _jwtHelper.GetEmail(HttpContext); var session = _magazijnSessionDataMapper.Find(m => m.MedewerkerEmail == email).FirstOrDefault(); var bestelling = session != null ? _bestellingDataMapper.GetByFactuurnummer(session.Factuurnummer) : _bestellingDataMapper .Find(f => f.BestelStatus == BffWebshopBestelStatus.Goedgekeurd) .OrderBy(b => b.Besteldatum) .FirstOrDefault(); if (bestelling == null) { _logger.LogInformation("Couldn't find any bestelling that has status: Goedgekeurd"); return(NoContent()); } try { if (session == null) { await VerstuurUpdateBestelStatus(bestelling.Factuurnummer, BffWebshopBestelStatus.WordtIngepakt); _magazijnSessionDataMapper.Insert(new MagazijnSessionEntity { Factuurnummer = bestelling.Factuurnummer, MedewerkerEmail = email }); } return(bestelling); } catch (TimeoutException) { _logger.LogError("UpdateBestelStatusCommand resulted in a TimeoutException."); return(StatusCode((int)HttpStatusCode.RequestTimeout, "Aanvraag kon niet worden verwerkt")); } catch (Exception ex) { _logger.LogError("UpdateBestelStatusCommand after GetNextOrder resulted in an error."); _logger.LogDebug( "Exception occured during execution of UpdateBestelStatusCommand when getting next order, it threw exception: {}. Inner exception: {}", ex.Message, ex.InnerException?.Message ); return(StatusCode( (int)HttpStatusCode.InternalServerError, "Er is een fout opgetreden tijdens het updaten van de bestelstatus" )); } }
public ActionResult <CommonModels.BffWebshop.KlantBeheer.Klant> Index() { var email = _jwtHelper.GetEmail(HttpContext); var klant = _klantDataMapper.GetByEmail(email); return(klant); }