예제 #1
0
        public async Task <ActionResult> AddTransitState(Guid id, AddTransitStateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var countries = await mediator.SendAsync(new GetAllCountriesHavingCompetentAuthorities());

                model.Countries = new SelectList(countries, "Id", "Name");

                var result = await mediator.SendAsync(new GetTransitAuthoritiesAndEntryOrExitPointsByCountryId(model.CountryId.Value));

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

                model.CompetentAuthorities = competentAuthorityRadioButtons;
                model.EntryOrExitPoints    = new SelectList(result.EntryOrExitPoints, "Id", "Name");

                return(View(model));
            }

            await
            mediator.SendAsync(new AddTransitState(id, model.CountryId.Value, model.EntryPointId.Value,
                                                   model.ExitPointId.Value, model.CompetentAuthorities.SelectedValue));

            await this.auditService.AddAuditEntry(this.mediator,
                                                  id,
                                                  User.GetUserId(),
                                                  NotificationAuditType.Added,
                                                  NotificationAuditScreenType.Transits);

            return(RedirectToAction("Index", "Overview"));
        }
예제 #2
0
        public async Task <ActionResult> AddTransitState(Guid id)
        {
            var countries = await mediator.SendAsync(new GetAllCountriesHavingCompetentAuthorities());

            var model = new AddTransitStateViewModel
            {
                Countries = new SelectList(countries, "Id", "Name")
            };

            return(View(model));
        }
예제 #3
0
        public async Task <ActionResult> GetTransitAuthoritiesAndEntryOrExitPointsByCountryId(Guid countryId)
        {
            var model = new AddTransitStateViewModel();

            var result = await mediator.SendAsync(new GetTransitAuthoritiesAndEntryOrExitPointsByCountryId(countryId));

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

            model.CompetentAuthorities = competentAuthorityRadioButtons;
            model.EntryOrExitPoints    = new SelectList(result.EntryOrExitPoints, "Id", "Name");

            return(PartialView(model));
        }