예제 #1
0
 public EditViewModel(IEnumerable<MovementData> movements)
 {
     Shipments = new StringGuidRadioButtons(movements
         .OrderBy(m => m.Number)
         .Select(m => 
             new KeyValuePair<string, Guid>("Shipment " + m.Number, m.Id)));
 }
 public MovementReceiptViewModel(Guid id, IEnumerable<MovementData> model)
 {
     RadioButtons = new StringGuidRadioButtons(model
         .OrderBy(d => d.Number)
         .Select(d => new KeyValuePair<string, Guid>("Shipment " + d.Number, d.Id)));
     NotificationId = id;
 }
예제 #3
0
 public EditViewModel(IEnumerable <MovementData> movements)
 {
     Shipments = new StringGuidRadioButtons(movements
                                            .OrderBy(m => m.Number)
                                            .Select(m =>
                                                    new KeyValuePair <string, Guid>("Shipment " + m.Number, m.Id)));
 }
예제 #4
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"));
        }
예제 #5
0
        public ShipmentViewModel(Guid id, NotificationType notificationType, CertificateType certificate, IEnumerable <MovementData> receiveModel)
        {
            ReceiveShipments = new StringGuidRadioButtons(receiveModel
                                                          .OrderBy(d => d.Number)
                                                          .Select(d => new KeyValuePair <string, Guid>("Shipment " + d.Number, d.Id)));

            NotificationId   = id;
            NotificationType = notificationType;
            Certificate      = certificate;
        }
예제 #6
0
        public ShipmentViewModel(Guid id, NotificationType notificationType, CertificateType certificate, MovementOperationData recoveryModel)
        {
            var list = recoveryModel.MovementDatas;

            RecoveryShipments = new StringGuidRadioButtons(list
                                                           .OrderBy(d => d.Number)
                                                           .Select(d => new KeyValuePair <string, Guid>("Shipment " + d.Number, d.Id)));

            NotificationId   = id;
            NotificationType = notificationType;
            Certificate      = certificate;
        }
        public CompleteMovementViewModel(Guid id, MovementOperationData model)
        {
            var list = model.MovementDatas;

            RadioButtons = new StringGuidRadioButtons(list
                .OrderBy(d => d.Number)
                .Select(d => new KeyValuePair<string, Guid>("Shipment " + d.Number, d.Id)));

            NotificationId = id;

            NotificationType = model.NotificationType;
        }
예제 #8
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));
        }
예제 #9
0
        private async Task GetCompetentAuthoritiesAndCountriesForModel(TransitStateViewModel model)
        {
            if (!model.CountryId.HasValue)
            {
                return;
            }

            var entryPointsAndCompetentAuthorities =
                await
                mediator.SendAsync(new GetTransitAuthoritiesAndEntryOrExitPointsByCountryId(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.EntryOrExitPoints    = new SelectList(entryPointsAndCompetentAuthorities.EntryOrExitPoints, "Id", "Name");
        }
        private async Task GetCompetentAuthoritiesAndCountriesForModel(TransitStateViewModel model)
        {
            if (!model.CountryId.HasValue)
            {
                return;
            }

            var entryPointsAndCompetentAuthorities =
                await
                    mediator.SendAsync(new GetTransitAuthoritiesAndEntryOrExitPointsByCountryId(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.EntryOrExitPoints = new SelectList(entryPointsAndCompetentAuthorities.EntryOrExitPoints, "Id", "Name");
        }