public async Task <IActionResult> EditProposalExample(string scenarioId, string proposalId, AddProposalExampleModel model)
        {
            var scenario = await ScenarioModel.GetAsync(AppSettings.DefaultRepo, scenarioId);

            if (scenario == null)
            {
                return(NotFound());
            }

            var proposalExample = scenario.Proposals?.FirstOrDefault(i => i.ProposalId == proposalId);

            if (proposalExample == null)
            {
                return(NotFound());
            }

            using (await LockingService.LockAsync())
            {
                await BaseContentsModel.SaveContentsAsync(proposalExample.Id, AppSettings.DefaultRepo, model.Contents);

                await ChangesService.Get(AppSettings.DefaultRepo).PushChangesAsync();
            }

            dynamic parameters = new ExpandoObject();

            parameters.scenarioId = scenarioId;
            parameters.proposalId = proposalId;
            return(RedirectToAction(actionName: nameof(ViewProposalExample), routeValues: parameters));
        }
        public async Task <IActionResult> EditProposalExample(string scenarioId, string proposalId)
        {
            var scenario = await ScenarioModel.GetAsync(AppSettings.DefaultRepo, scenarioId);

            if (scenario == null)
            {
                return(NotFound());
            }

            var proposalExample = scenario.Proposals?.FirstOrDefault(i => i.ProposalId == proposalId);

            if (proposalExample == null)
            {
                return(NotFound());
            }

            await scenario.GetContentsAsync();

            await proposalExample.GetContentsAsync();

            var model = new AddProposalExampleModel();

            model.Scenario   = scenario;
            model.ProposalId = proposalId;
            model.Contents   = proposalExample.Contents;

            this.ViewBag.FormAction = "EditProposalExample";

            return(View("EditProposalExample", model));
        }
示例#3
0
        public async Task <IActionResult> ViewScenario(string id)
        {
            var scenario = await ScenarioModel.GetAsync(AppSettings.DefaultRepo, id);

            if (scenario == null)
            {
                return(Redirect("/scenarios"));
            }

            await scenario.GetContentsAsync();

            return(View(scenario));
        }
        public async Task <IActionResult> AddProposalExample(string scenarioId)
        {
            var map = await MapModel.GetAsync(AppSettings.DefaultRepo);

            var model = new AddProposalExampleModel();

            model.Scenario = await ScenarioModel.GetAsync(AppSettings.DefaultRepo, scenarioId);

            if (model.Scenario == null)
            {
                return(RedirectToAction(controllerName: nameof(ScenariosController), actionName: nameof(ScenariosController.Index)));
            }
            await model.Scenario.GetContentsAsync();

            model.AvailableProposals = (map.Proposals ?? new List <MapProposalModel>()).Where(i => !model.Scenario.Proposals.Exists(x => x.ProposalId == i.Id)).ToList();

            this.ViewBag.Adding     = true;
            this.ViewBag.FormAction = "AddProposalExample";

            return(View("EditProposalExample", model));
        }
        public async Task <IActionResult> ViewProposalExample(string scenarioId, string proposalId)
        {
            var scenario = await ScenarioModel.GetAsync(AppSettings.DefaultRepo, scenarioId);

            if (scenario == null)
            {
                return(RedirectToAction(nameof(ScenariosController.Index), nameof(ScenariosController)));
            }

            var proposalExample = scenario.Proposals?.FirstOrDefault(i => i.Info.Id == proposalId);

            if (proposalExample == null)
            {
                return(RedirectToAction(nameof(ScenariosController.Index), nameof(ScenariosController)));
            }

            await scenario.GetContentsAsync();

            await proposalExample.GetContentsAsync();

            return(View(proposalExample));
        }