public async Task<ActionResult> Index(Guid id)
        {
            var data = await mediator.SendAsync(new GetExitCustomsOfficeAddDataByNotificationId(id));

            if (data.CustomsOffices != CustomsOffices.EntryAndExit
                && data.CustomsOffices != CustomsOffices.Exit)
            {
                return RedirectToAction("Index", "CustomsOffice", new { id });
            }

            CustomsOfficeViewModel model;
            if (data.CustomsOfficeData != null)
            {
                model = new CustomsOfficeViewModel
                {
                    Address = data.CustomsOfficeData.Address,
                    Name = data.CustomsOfficeData.Name,
                    SelectedCountry = data.CustomsOfficeData.Country.Id,
                    Countries = new SelectList(data.Countries, "Id", "Name", data.CustomsOfficeData.Country.Id),
                    Steps = (data.CustomsOffices == CustomsOffices.EntryAndExit) ? 2 : 1
                };
            }
            else
            {
                model = new CustomsOfficeViewModel
                {
                    Countries = new SelectList(data.Countries, "Id", "Name"),
                    Steps = (data.CustomsOffices == CustomsOffices.EntryAndExit) ? 2 : 1
                };
            }

            return View(model);
        }
        //public IList<MergeField> AnnexMergeFields { get; private set; }

        public CustomsOfficeBlock(IList<MergeField> mergeFields, TransportRoute transportRoute)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new CustomsOfficeViewModel(transportRoute);

            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
        }
        public async Task<ActionResult> Index(Guid id, CustomsOfficeViewModel model)
        {
            var countries = await mediator.SendAsync(new GetEuropeanUnionCountries());

            model.Countries = model.SelectedCountry.HasValue
                ? new SelectList(countries, "Id", "Name", model.SelectedCountry.Value)
                : new SelectList(countries, "Id", "Name");

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

            CustomsOfficeCompletionStatus result = await mediator.SendAsync(
                new SetExitCustomsOfficeForNotificationById(id,
                model.Name,
                model.Address,
                model.SelectedCountry.Value));

            switch (result.CustomsOfficesRequired)
            {
                case CustomsOffices.EntryAndExit:
                    return RedirectToAction("Index", "EntryCustomsOffice", new { id });
                default:
                    return RedirectToAction("Index", "Shipment", new { id });
            }
        }
예제 #4
0
        public async Task <ActionResult> Index(Guid id, CustomsOfficeViewModel model, bool?backToOverview = null)
        {
            var countries = await mediator.SendAsync(new GetEuropeanUnionCountries());

            model.Countries = model.SelectedCountry.HasValue
                ? new SelectList(countries, "Id", "Name", model.SelectedCountry.Value)
                : new SelectList(countries, "Id", "Name");

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

            var existingData = await mediator.SendAsync(new GetExitCustomsOfficeAddDataByNotificationId(id));

            NotificationAuditType auditType = NotificationAuditType.Added;

            if (model.CustomsOfficeRequired.GetValueOrDefault())
            {
                await mediator.SendAsync(
                    new SetExitCustomsOfficeForNotificationById(id,
                                                                model.Name,
                                                                model.Address,
                                                                model.SelectedCountry.Value));

                auditType = existingData.CustomsOfficeData == null ? NotificationAuditType.Added : NotificationAuditType.Updated;
            }
            else if (existingData.CustomsOfficeData != null)
            {
                // If customs office required is set to false but there is existing data in the database, delete it
                await mediator.SendAsync(new DeleteExitCustomsOfficeByNotificationId(id));

                auditType = NotificationAuditType.Deleted;
            }

            await this.auditService.AddAuditEntry(this.mediator,
                                                  id,
                                                  User.GetUserId(),
                                                  auditType,
                                                  NotificationAuditScreenType.CustomsOffice);

            var addSelection = await mediator.SendAsync(new SetExitCustomsOfficeSelectionForNotificationById(id, model.CustomsOfficeRequired.GetValueOrDefault()));

            var notificationCompetentAutority = await mediator.SendAsync(new GetNotificationCompetentAuthority(id));

            if (notificationCompetentAutority.Equals(UKCompetentAuthority.NorthernIreland))
            {
                return(RedirectToAction("Index", "EntryCustomsOffice", new { id, backToOverview = backToOverview }));
            }

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

            return(RedirectToAction("Index", "Shipment", new { id }));
        }
예제 #5
0
        public CustomsOfficeBlock(IList <MergeField> mergeFields, TransportRoute transportRoute, UKCompetentAuthority notificationCompetentAuthority)
        {
            IsNorthenIrelandCompetentAuthority = (notificationCompetentAuthority.Equals(UKCompetentAuthority.NorthernIreland) ? true : false);

            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);
            data = new CustomsOfficeViewModel(transportRoute);

            AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName);
        }
 public CustomsOfficeViewModelTests()
 {
     this.model = new CustomsOfficeViewModel
     {
         Address = AnyAddress,
         Name = AnyName,
         SelectedCountry = Guid.Empty
     };
 }
예제 #7
0
 public CustomsOfficeViewModelTests()
 {
     this.model = new CustomsOfficeViewModel
     {
         Address               = AnyAddress,
         Name                  = AnyName,
         SelectedCountry       = Guid.Empty,
         CustomsOfficeRequired = true
     };
 }
예제 #8
0
        public async Task <ActionResult> Index(Guid id, bool?backToOverview = null)
        {
            var data = await mediator.SendAsync(new GetEntryCustomsOfficeAddDataByNotificationId(id));

            if (data.CustomsOfficesRequired != CustomsOffices.EntryAndExit &&
                data.CustomsOfficesRequired != CustomsOffices.Entry)
            {
                return(RedirectToAction("Index", "CustomsOffice", new { id }));
            }

            CustomsOfficeViewModel model;

            if (data.CustomsOfficeData != null)
            {
                model = new CustomsOfficeViewModel
                {
                    Address         = data.CustomsOfficeData.Address,
                    Name            = data.CustomsOfficeData.Name,
                    SelectedCountry = data.CustomsOfficeData.Country.Id,
                    Countries       = new SelectList(data.Countries, "Id", "Name", data.CustomsOfficeData.Country.Id),
                    Steps           = (data.CustomsOfficesRequired == CustomsOffices.EntryAndExit) ? 2 : 1
                };
            }
            else
            {
                model = new CustomsOfficeViewModel
                {
                    Countries             = new SelectList(data.Countries, "Id", "Name"),
                    Steps                 = (data.CustomsOfficesRequired == CustomsOffices.EntryAndExit) ? 2 : 1,
                    CustomsOfficeRequired = true
                };
            }

            var existing = await mediator.SendAsync(new GetEntryExitCustomsOfficeSelectionForNotificationById(id));

            if (existing == null)
            {
                model.CustomsOfficeRequired = null;
            }
            else
            {
                model.CustomsOfficeRequired = existing.Entry;
            }

            return(View(model));
        }
        public async Task<ActionResult> Index(Guid id, CustomsOfficeViewModel model)
        {
            var countries = await mediator.SendAsync(new GetEuropeanUnionCountries());

            model.Countries = model.SelectedCountry.HasValue
                ? new SelectList(countries, "Id", "Name", model.SelectedCountry.Value)
                : new SelectList(countries, "Id", "Name");

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

            await mediator.SendAsync(new SetEntryCustomsOfficeForNotificationById(id,
                model.Name,
                model.Address,
                model.SelectedCountry.Value));

            return RedirectToAction("Index", "Shipment", new { id });
        }