Esempio n. 1
0
        public async Task <IActionResult> Get(QueryTrains.Request request)
        {
            if (request == null)
            {
                return(BadRequest($"{typeof(QueryTrains.Request)} is null"));
            }

            try
            {
                var session = _ssp.Create(TimeSpan.FromDays(1));

                var result = await _rail.QueryTrainsAsync(session, request);

                await _ssp.SaveAsync(session);

                return(Ok(new GetTrainsResult
                {
                    SessionId = session.Id,
                    Trains = result.Trains
                }));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "GetTrains failed");

                return(StatusCode(500));
            }
        }
        public ISession GetActiveSession()
        {
            if (Current == null)
            {
                Current = _provider.Create();
            }

            return(Current);
        }
Esempio n. 3
0
        public ISession GetActiveSession()
        {
            if (Current == null)
            {
                var session = _provider.Create();

                Current = session;

                return(session);
            }

            return(Current);
        }