Example #1
0
        private ActionResult ChangeCountryAction(StateOfImportViewModel model)
        {
            ModelState.Clear();
            model.ShowNextSection = false;

            return(View("Index", model));
        }
        private ActionResult ChangeCountryAction(StateOfImportViewModel model)
        {
            ModelState.Clear();
            model.ShowNextSection = false;

            return View("Index", model);
        }
Example #3
0
        private async Task <SelectList> GetCountrySelectListForModel(StateOfImportViewModel model)
        {
            var countries = await mediator.SendAsync(new GetAllCountriesHavingCompetentAuthorities());

            return((model.CountryId.HasValue)
                ? new SelectList(countries, "Id", "Name", model.CountryId.Value)
                : new SelectList(countries, "Id", "Name"));
        }
        private async Task<ActionResult> SubmitAction(Guid id, StateOfImportViewModel model, bool? backToOverview)
        {
            await mediator.SendAsync(new SetStateOfImportForNotification(id,
                    model.CountryId.Value,
                    model.EntryOrExitPointId.Value,
                    model.CompetentAuthorities.SelectedValue));

            if (backToOverview.GetValueOrDefault())
            {
                return RedirectToAction("Index", "Home", new { id });
            }
            else
            {
                return RedirectToAction("Summary", "TransportRoute", new { id });
            }
        }
Example #5
0
        public async Task <ActionResult> Index(Guid id, StateOfImportViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var stateOfImport = new StateOfImport(id)
            {
                CompetentAuthorityId = model.CompetentAuthorityId,
                EntryPointId         = model.EntryPointId
            };

            await mediator.SendAsync(new SetDraftData <StateOfImport>(id, stateOfImport));

            return(RedirectToAction("Index", "TransitState"));
        }
Example #6
0
        public async Task <ActionResult> Index(Guid id)
        {
            var stateOfImport = await mediator.SendAsync(new GetDraftData <StateOfImport>(id));

            var lookupData = await mediator.SendAsync(new GetUnitedKingdomCompetentAuthoritiesAndEntryOrExitPoints());

            var model = new StateOfImportViewModel(stateOfImport);

            if (!stateOfImport.CompetentAuthorityId.HasValue)
            {
                model.CompetentAuthorityId =
                    (await mediator.SendAsync(new GetInternalUserCompetentAuthority())).Item2.Id;
            }

            model.CompetentAuthorities = lookupData.CompetentAuthorities;
            model.EntryPoints          = lookupData.EntryOrExitPoints;

            return(View(model));
        }
        public async Task<ActionResult> Index(Guid id, StateOfImportViewModel model, string submit, bool? backToOverview = null)
        {
            model.Countries = await GetCountrySelectListForModel(model);
            await GetCompetentAuthoritiesAndEntryPoints(model);

            if (!ModelState.IsValid && submit != ChangeCountry)
            {
                return View(model);
            }

            switch (submit)
            {
                case SelectCountry:
                    return SelectCountryAction(model);
                case ChangeCountry:
                    return ChangeCountryAction(model);
                default:
                    return await SubmitAction(id, model, backToOverview);
            }
        }
Example #8
0
        public async Task <ActionResult> Index(Guid id, StateOfImportViewModel model, string submit, bool?backToOverview = null)
        {
            model.Countries = await GetCountrySelectListForModel(model);
            await GetCompetentAuthoritiesAndEntryPoints(model);

            if (!ModelState.IsValid && submit != ChangeCountry)
            {
                return(View(model));
            }

            switch (submit)
            {
            case SelectCountry:
                return(SelectCountryAction(model));

            case ChangeCountry:
                return(ChangeCountryAction(model));

            default:
                return(await SubmitAction(id, model, backToOverview));
            }
        }
Example #9
0
        private async Task GetCompetentAuthoritiesAndEntryPoints(StateOfImportViewModel model)
        {
            if (!model.CountryId.HasValue)
            {
                return;
            }

            var entryPointsAndCompetentAuthorities =
                await
                mediator.SendAsync(new GetCompetentAuthoritiesAndEntryPointsByCountryId(model.CountryId.Value, model.NotificationCompetentAuthority));

            var competentAuthoritiesKeyValuePairs = entryPointsAndCompetentAuthorities.CompetentAuthorities.Select(ca =>
                                                                                                                   new KeyValuePair <string, Guid>(ca.Code + " -" + ca.Name, ca.Id));
            var competentAuthorityRadioButtons = new StringGuidRadioButtons(competentAuthoritiesKeyValuePairs);

            if (model.CompetentAuthorities != null)
            {
                competentAuthorityRadioButtons.SelectedValue = model.CompetentAuthorities.SelectedValue;
            }

            model.CompetentAuthorities = competentAuthorityRadioButtons;
            model.EntryPoints          = new SelectList(entryPointsAndCompetentAuthorities.EntryOrExitPoints, "Id", "Name");
        }
Example #10
0
        private async Task <ActionResult> SubmitAction(Guid id, StateOfImportViewModel model, bool?backToOverview)
        {
            var stateOfImportSetData = await mediator.SendAsync(new GetStateOfImportWithTransportRouteDataByNotificationId(id));

            await mediator.SendAsync(new SetStateOfImportForNotification(id,
                                                                         model.CountryId.Value,
                                                                         model.EntryOrExitPointId.Value,
                                                                         model.CompetentAuthorities.SelectedValue));

            await this.auditService.AddAuditEntry(this.mediator,
                                                  id,
                                                  User.GetUserId(),
                                                  stateOfImportSetData.StateOfImport == null?NotificationAuditType.Added : NotificationAuditType.Updated,
                                                  NotificationAuditScreenType.ImportRoute);

            if (backToOverview.GetValueOrDefault())
            {
                return(RedirectToAction("Index", "Home", new { id }));
            }
            else
            {
                return(RedirectToAction("Summary", "TransportRoute", new { id }));
            }
        }
        private ActionResult SelectCountryAction(StateOfImportViewModel model)
        {
            model.ShowNextSection = true;

            return View("Index", model);
        }
        private async Task GetCompetentAuthoritiesAndEntryPoints(StateOfImportViewModel model)
        {
            if (!model.CountryId.HasValue)
            {
                return;
            }

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

            var competentAuthoritiesKeyValuePairs = entryPointsAndCompetentAuthorities.CompetentAuthorities.Select(ca =>
                new KeyValuePair<string, Guid>(ca.Code + " -" + ca.Name, ca.Id));
            var competentAuthorityRadioButtons = new StringGuidRadioButtons(competentAuthoritiesKeyValuePairs);

            if (model.CompetentAuthorities != null)
            {
                competentAuthorityRadioButtons.SelectedValue = model.CompetentAuthorities.SelectedValue;
            }

            model.CompetentAuthorities = competentAuthorityRadioButtons;
            model.EntryPoints = new SelectList(entryPointsAndCompetentAuthorities.EntryOrExitPoints, "Id", "Name");
        }
        private async Task<SelectList> GetCountrySelectListForModel(StateOfImportViewModel model)
        {
            var countries = await mediator.SendAsync(new GetAllCountriesHavingCompetentAuthorities());

            return (model.CountryId.HasValue)
                ? new SelectList(countries, "Id", "Name", model.CountryId.Value)
                : new SelectList(countries, "Id", "Name");
        }
Example #14
0
        private ActionResult SelectCountryAction(StateOfImportViewModel model)
        {
            model.ShowNextSection = true;

            return(View("Index", model));
        }