Пример #1
0
        private async Task <ActionResult> SubmitAction(Guid id, Guid?transitStateId, TransitStateViewModel model, bool?backToOverview)
        {
            try
            {
                TransitStateWithTransportRouteData existingData = await mediator.SendAsync(new GetTransitStateWithTransportRouteDataByNotificationId(id, transitStateId));

                var request = new SetTransitStateForNotification(id,
                                                                 model.CountryId.Value,
                                                                 model.EntryPointId.Value,
                                                                 model.ExitPointId.Value,
                                                                 model.CompetentAuthorities.SelectedValue,
                                                                 transitStateId,
                                                                 model.OrdinalPosition);

                await mediator.SendAsync(request);

                await this.auditService.AddAuditEntry(this.mediator,
                                                      id,
                                                      User.GetUserId(),
                                                      existingData.TransitState == null?NotificationAuditType.Added : NotificationAuditType.Updated,
                                                      NotificationAuditScreenType.Transits);

                return(RedirectToAction("Summary", "TransportRoute", new { id, backToOverview }));
            }
            catch (ApiException)
            {
                ModelState.AddModelError(string.Empty, "Error saving this record. You may already have saved this record, return to the summary to edit this record.");
            }
            return(View(model));
        }
Пример #2
0
        public async Task <ActionResult> Index(Guid id, Guid?entityId, bool?backToOverview)
        {
            ViewBag.BackToOverview = backToOverview.GetValueOrDefault();

            TransitStateWithTransportRouteData result =
                await
                mediator.SendAsync(new GetTransitStateWithTransportRouteDataByNotificationId(id, entityId));

            var notificationCompetentAuthority = await mediator.SendAsync(new GetUnitedKingdomCompetentAuthorityByNotificationId(id));

            var model = transitStateMapper.Map(result);

            model.NotificationCompetentAuthority = notificationCompetentAuthority.AsUKCompetantAuthority();

            return(View(model));
        }