public async Task <IActionResult> Cars(string sessionId, int optionRef) { try { var session = await _ssp.LoadAsync(sessionId); var result = await _rail.QueryCarsAsync(session, new QueryCars.Request(optionRef)); await _ssp.SaveAsync(session); return(new JsonResult(new GetCarsResult { SessionId = sessionId, TrainOption = optionRef, Cars = result.Cars, InsuranceProviders = result.InsuranceProviders, AgeLimits = result.AgeLimits })); } catch (Exception ex) { _logger.LogError(ex, "GetCars failed"); return(StatusCode(500)); } }
public async Task <IActionResult> Create([FromBody] QueryReserveCreate.Request request) { if (request == null) { return(BadRequest(ModelState)); } _logger.LogInformation($"Rail reserve attempt SessionId: {request.Option.SessionId}, CarOptionRef: {request.Option.CarOptionRef}"); var session = await _ssp.LoadAsync(request.Option.SessionId); if (session == null) { return(SessionExpired()); } try { var result = await _rail.CreateReserveAsync(session, request); await _ssp.SaveAsync(session); return(Ok(result)); } catch (Services.PassRzdRu.Parser.ParserException ex) { _logger.LogError(LogEventId.RESERVE_TICKET_FAIL, ex, $"{nameof(_rail.CreateReserveAsync)} failed, SessionId: {session.Id}, Request: {request}"); return(StatusCode((int)HttpStatusCode.InternalServerError, new { message = ex.Message })); } catch (Exception ex) { _logger.LogError(LogEventId.RESERVE_TICKET_FAIL, ex, $"{nameof(_rail.CreateReserveAsync)} failed, SessionId: {session.Id}, Request: {request}"); return(BadRequest()); } }