コード例 #1
0
        public async Task <ActionResult> Index(Guid id, StateOfExportViewModel model, string submit, bool?backToOverview = null)
        {
            await GetCompetentAuthoritiesAndEntryPoints(mediator, model);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            return(await SubmitAction(id, model, mediator, backToOverview));
        }
コード例 #2
0
        public async Task<ActionResult> GetAuthoritiesAndExitPoints(Guid countryId)
        {
            var data = await mediator.SendAsync(new GetCompetentAuthoritiesAndEntryOrExitPointsByCountryId(countryId));

            var model = new StateOfExportViewModel
            {
                CompetentAuthorities = data.CompetentAuthorities,
                ExitPoints = data.EntryOrExitPoints
            };

            return PartialView("_CompetentAuthoritiesAndExitPoints", model);
        } 
コード例 #3
0
        public async Task <ActionResult> GetAuthoritiesAndExitPoints(Guid countryId)
        {
            var data = await mediator.SendAsync(new GetCompetentAuthoritiesAndEntryOrExitPointsByCountryId(countryId));

            var model = new StateOfExportViewModel
            {
                CompetentAuthorities = data.CompetentAuthorities,
                ExitPoints           = data.EntryOrExitPoints
            };

            return(PartialView("_CompetentAuthoritiesAndExitPoints", model));
        }
コード例 #4
0
        private async Task GetCompetentAuthoritiesAndEntryPoints(IMediator mediator, StateOfExportViewModel model)
        {
            if (!model.CountryId.HasValue)
            {
                return;
            }

            var entryPointsAndCompetentAuthorities =
                await
                mediator.SendAsync(new GetCompetentAuthoritiesAndEntryOrExitPointsByCountryId(model.CountryId.Value));

            model.ExitPoints = new SelectList(entryPointsAndCompetentAuthorities.EntryOrExitPoints, "Id", "Name");
        }
コード例 #5
0
        public async Task<ActionResult> Index(Guid id, StateOfExportViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var stateOfExport = new StateOfExport(id)
            {
                CompetentAuthorityId = model.CompetentAuthorityId,
                CountryId = model.CountryId,
                ExitPointId = model.ExitPointId
            };

            await mediator.SendAsync(new SetDraftData<StateOfExport>(id, stateOfExport));

            return RedirectToAction("Index", "StateOfImport");
        }
コード例 #6
0
        public async Task <ActionResult> Index(Guid id, StateOfExportViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var stateOfExport = new StateOfExport(id)
            {
                CompetentAuthorityId = model.CompetentAuthorityId,
                CountryId            = model.CountryId,
                ExitPointId          = model.ExitPointId
            };

            await mediator.SendAsync(new SetDraftData <StateOfExport>(id, stateOfExport));

            return(RedirectToAction("Index", "StateOfImport"));
        }
コード例 #7
0
        private async Task <ActionResult> SubmitAction(Guid id, StateOfExportViewModel model, IMediator mediator, bool?backToOverview)
        {
            var stateOfExportSetData = await mediator.SendAsync(new GetStateOfExportWithTransportRouteDataByNotificationId(id));

            await mediator.SendAsync(new SetStateOfExportForNotification(id, model.EntryOrExitPointId.Value));

            await this.auditService.AddAuditEntry(this.mediator,
                                                  id,
                                                  User.GetUserId(),
                                                  stateOfExportSetData.StateOfExport.ExitPoint == null?NotificationAuditType.Added : NotificationAuditType.Updated,
                                                  NotificationAuditScreenType.ExportRoute);

            if (backToOverview.GetValueOrDefault())
            {
                return(RedirectToAction("Index", "Home", new { id }));
            }

            return(RedirectToAction("Index", "StateOfImport", new { id }));
        }
コード例 #8
0
        public async Task<ActionResult> Index(Guid id)
        {
            var stateOfExport = await mediator.SendAsync(new GetDraftData<StateOfExport>(id));

            var model = new StateOfExportViewModel(stateOfExport);

            model.Countries = await mediator.SendAsync(new GetCountries());

            if (model.IsCountrySelected)
            {
                var data =
                    await
                        mediator.SendAsync(
                            new GetCompetentAuthoritiesAndEntryOrExitPointsByCountryId(model.CountryId.Value));

                model.CompetentAuthorities = data.CompetentAuthorities;
                model.ExitPoints = data.EntryOrExitPoints;
            }

            return View(model);
        }
コード例 #9
0
        public async Task <ActionResult> Index(Guid id)
        {
            var stateOfExport = await mediator.SendAsync(new GetDraftData <StateOfExport>(id));

            var model = new StateOfExportViewModel(stateOfExport);

            model.Countries = await mediator.SendAsync(new GetCountries());

            if (model.IsCountrySelected)
            {
                var data =
                    await
                    mediator.SendAsync(
                        new GetCompetentAuthoritiesAndEntryOrExitPointsByCountryId(model.CountryId.Value));

                model.CompetentAuthorities = data.CompetentAuthorities;
                model.ExitPoints           = data.EntryOrExitPoints;
            }

            return(View(model));
        }