public ExporterWindow()
        {
            InitializeComponent();

            vm = new ExporterViewModel(this);
            this.DataContext = vm;
        }
        public ExporterSelection(SDGuiStrings strings, ICoreConfigSection sharpdoxConfig, IExporter[] allExporters)
        {
            Strings = strings;

            DataContext = new ExporterViewModel(sharpdoxConfig, allExporters);
            InitializeComponent();
        }
        public async Task<ActionResult> Index(ExporterViewModel model, bool? backToOverview = null)
        {
            if (!ModelState.IsValid)
            {
                await this.BindCountryList(mediator);
                return View(model);
            }

            try
            {
                await mediator.SendAsync(model.ToRequest());

                await AddToProducerAddressBook(model);

                if (backToOverview.GetValueOrDefault())
                {
                    return RedirectToAction("Index", "Home", new { id = model.NotificationId });
                }
                else
                {
                    return RedirectToAction("List", "Producer", new { id = model.NotificationId });
                }
            }
            catch (ApiBadRequestException ex)
            {
                this.HandleBadRequest(ex);
                if (ModelState.IsValid)
                {
                    throw;
                }
            }

            await this.BindCountryList(mediator);
            return View(model);
        }
Exemplo n.º 4
0
        public ActionResult UpdateExporter(ExporterViewModel exorter)
        {
            var exporterDataService = new ExporterDataService();
            var result = exporterDataService.UpdateExporter(exorter);

            return(Json(result ? new AjaxResult(true) : new AjaxResult(false)));
        }
Exemplo n.º 5
0
        private async Task AddToProducerAddressBook(ExporterViewModel model)
        {
            if (!model.IsAddedToAddressBook)
            {
                return;
            }

            var addressRecord = addressBookMapper.Map(model, AddressRecordType.Producer);

            await mediator.SendAsync(addressRecord);
        }
        public async Task<ActionResult> Index(Guid id)
        {
            var exporter = await mediator.SendAsync(new GetDraftData<Exporter>(id));

            var countries = await mediator.SendAsync(new GetCountries());

            var model = new ExporterViewModel(exporter);

            model.Address.Countries = countries;

            return View(model);
        }
        public async Task <ActionResult> Index(Guid id)
        {
            var exporter = await mediator.SendAsync(new GetDraftData <Exporter>(id));

            var countries = await mediator.SendAsync(new GetCountries());

            var model = new ExporterViewModel(exporter);

            model.Address.Countries = countries;

            return(View(model));
        }
Exemplo n.º 8
0
        private BusinessInfoData RemoveRegistrationNumberDataForProducer(ExporterViewModel model)
        {
            var businessData = model.Business.ToBusinessInfoData();

            if (businessData.BusinessType != BusinessType.LimitedCompany)
            {
                businessData.RegistrationNumber = null;
            }

            businessData.AdditionalRegistrationNumber = null;

            return(businessData);
        }
Exemplo n.º 9
0
        public AddAddressBookEntry Map(ExporterViewModel source, AddressRecordType parameter)
        {
            switch (parameter)
            {
            case AddressRecordType.Producer:
                return(new AddAddressBookEntry
                {
                    Address = source.Address,
                    Business = RemoveRegistrationNumberDataForProducer(source),
                    Contact = source.Contact,
                    Type = AddressRecordType.Producer
                });

            default:
                throw new InvalidOperationException();
            }
        }
Exemplo n.º 10
0
        public async Task <ActionResult> Index(ExporterViewModel model, bool?backToOverview = null)
        {
            if (!ModelState.IsValid)
            {
                await this.BindCountryList(mediator);

                return(View(model));
            }

            try
            {
                var exporter = await mediator.SendAsync(new GetExporterByNotificationId(model.NotificationId));

                await mediator.SendAsync(model.ToRequest());

                await AddToProducerAddressBook(model);

                await this.auditService.AddAuditEntry(this.mediator,
                                                      model.NotificationId,
                                                      User.GetUserId(),
                                                      exporter.HasExporter?NotificationAuditType.Updated : NotificationAuditType.Added,
                                                      NotificationAuditScreenType.Exporter);

                if (backToOverview.GetValueOrDefault())
                {
                    return(RedirectToAction("Index", "Home", new { id = model.NotificationId }));
                }
                else
                {
                    return(RedirectToAction("List", "Producer", new { id = model.NotificationId }));
                }
            }
            catch (ApiBadRequestException ex)
            {
                this.HandleBadRequest(ex);
                if (ModelState.IsValid)
                {
                    throw;
                }
            }

            await this.BindCountryList(mediator);

            return(View(model));
        }
        public async Task<ActionResult> Index(Guid id, ExporterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var exporter = new Exporter(id)
            {
                Address = model.Address.AsAddress(),
                BusinessName = model.BusinessName,
                Contact = model.Contact.AsContact()
            };

            await mediator.SendAsync(new SetDraftData<Exporter>(id, exporter));

            return RedirectToAction("Index", "Importer");
        }
        public async Task <ActionResult> Index(Guid id, ExporterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var exporter = new Exporter(id)
            {
                Address              = model.Address.AsAddress(),
                BusinessName         = model.Business.Name,
                Contact              = model.Contact.AsContact(),
                IsAddedToAddressBook = model.IsAddedToAddressBook
            };

            await mediator.SendAsync(new SetDraftData <Exporter>(id, exporter));

            return(RedirectToAction("Index", "Importer"));
        }
        public async Task<ActionResult> Index(Guid id, bool? backToOverview = null)
        {
            ExporterViewModel model;
            var exporter = await mediator.SendAsync(new GetExporterByNotificationId(id));
            if (exporter.HasExporter)
            {
                model = new ExporterViewModel(exporter);
            }
            else
            {
                model = new ExporterViewModel
                {
                    NotificationId = id
                };
            }

            await this.BindCountryList(mediator);
            model.Address.DefaultCountryId = this.GetDefaultCountryId();
            return View(model);
        }
Exemplo n.º 14
0
        public async Task <ActionResult> Index(Guid id, bool?backToOverview = null)
        {
            ExporterViewModel model;
            var exporter = await mediator.SendAsync(new GetExporterByNotificationId(id));

            if (exporter.HasExporter)
            {
                model = new ExporterViewModel(exporter);
            }
            else
            {
                model = new ExporterViewModel
                {
                    NotificationId = id
                };
            }

            await this.BindCountryList(mediator);

            model.Address.DefaultCountryId = this.GetDefaultCountryId();
            return(View(model));
        }
Exemplo n.º 15
0
 public ActionResult CreateExporter(ExporterViewModel exporter)
 {
     new ExporterDataService().CreateExporter(exporter);
     return(Json(new AjaxResult(true)));
 }
        private async Task AddToProducerAddressBook(ExporterViewModel model)
        {
            if (!model.IsAddedToAddressBook)
            {
                return;
            }

            var addressRecord = addressBookMapper.Map(model, AddressRecordType.Producer);
                
            await mediator.SendAsync(addressRecord);
        }
Exemplo n.º 17
0
        public ExporterBlock(IList<MergeField> mergeFields, Exporter exporter)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);

            data = new ExporterViewModel(exporter);
        }
Exemplo n.º 18
0
        public ExporterBlock(IList <MergeField> mergeFields, Exporter exporter)
        {
            CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName);

            data = new ExporterViewModel(exporter);
        }