示例#1
0
        public async Task <VmPage <VmScenarioSummary> > GetAll([FromQuery] ScenarioSummaryApiParams scenarioSummaryParams)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpStatusCodeException(HttpStatusCode.BadRequest, ModelState.Errors());
            }

            var validFilters = scenarioSummaryParams.GetValidFilters();

            var sorts = scenarioSummaryParams.GetSorts();

            var results = await _scenarioWebService.GetAll(
                validFilters,
                sorts,
                scenarioSummaryParams.PageIndex,
                scenarioSummaryParams.PageLimit
                );

            return(new VmPage <VmScenarioSummary>
            {
                Items = VmScenarioSummary.Build(results),
                PageIndex = results.PageIndex,
                PageSize = results.PageSize,
                TotalCount = results.Total
            });
        }
示例#2
0
        public async Task <VmScenarioSummary> Get(int scenarioId, int clientId = 0)
        {
            if (scenarioId <= 0)
            {
                throw new HttpStatusCodeException(HttpStatusCode.BadRequest);
            }

            if (!_organisationDataProvider.ScenarioIds.Contains(scenarioId))
            {
                throw new HttpStatusCodeException(HttpStatusCode.Unauthorized);
            }

            var result = await _scenarioWebService.Get(clientId, scenarioId);

            return(VmScenarioSummary.Build(result));
        }