public async Task<ActionResult> Index(ImporterViewModel model, bool? backToOverview = null) { if (!ModelState.IsValid) { await this.BindCountryList(mediator, false); 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", "Facility", new { id = model.NotificationId }); } } catch (ApiBadRequestException ex) { this.HandleBadRequest(ex); if (ModelState.IsValid) { throw; } } await this.BindCountryList(mediator, false); return View(model); }
public ImporterView() { DataContext = new ImporterViewModel(); InitializeComponent(); //textBox1.Text = "XML document..."; //textBox1.Foreground = Brushes.DarkSlateGray; }
private async Task AddToProducerAddressBook(ImporterViewModel model) { if (!model.IsAddedToAddressBook) { return; } var addressRecord = addressBookMapper.Map(model, AddressRecordType.Facility); await mediator.SendAsync(addressRecord); }
public async Task <ActionResult> Index(Guid id) { var importer = await mediator.SendAsync(new GetDraftData <Importer>(id)); var model = new ImporterViewModel(importer); var countries = await mediator.SendAsync(new GetCountries()); model.Address.Countries = countries; model.DefaultUkIfUnselected(countries); return(View(model)); }
public async Task<ActionResult> Index(Guid id) { var importer = await mediator.SendAsync(new GetDraftData<Importer>(id)); var model = new ImporterViewModel(importer); var countries = await mediator.SendAsync(new GetCountries()); model.Address.Countries = countries; model.DefaultUkIfUnselected(countries); return View(model); }
public async Task<ActionResult> Index(Guid id, bool? backToOverview = null) { ImporterViewModel model; var importer = await mediator.SendAsync(new GetImporterByNotificationId(id)); if (importer.HasImporter) { model = new ImporterViewModel(importer); } else { model = new ImporterViewModel { NotificationId = id }; } await this.BindCountryList(mediator, false); model.Address.DefaultCountryId = this.GetDefaultCountryId(); return View(model); }
public AddAddressBookEntry Map(ImporterViewModel source, AddressRecordType parameter) { switch (parameter) { case AddressRecordType.Facility: return(new AddAddressBookEntry { Address = source.Address, Business = source.Business.ToBusinessInfoData(), Contact = source.Contact, Type = AddressRecordType.Facility }); default: throw new InvalidOperationException(); } }
public async Task <ActionResult> Index(ImporterViewModel model, bool?backToOverview = null) { if (!ModelState.IsValid) { await this.BindCountryList(mediator, false); return(View(model)); } try { var importer = await mediator.SendAsync(new GetImporterByNotificationId(model.NotificationId)); await mediator.SendAsync(model.ToRequest()); await this.auditService.AddAuditEntry(this.mediator, model.NotificationId, User.GetUserId(), importer.HasImporter?NotificationAuditType.Updated : NotificationAuditType.Added, NotificationAuditScreenType.Importer); await AddToProducerAddressBook(model); if (backToOverview.GetValueOrDefault()) { return(RedirectToAction("Index", "Home", new { id = model.NotificationId })); } else { return(RedirectToAction("List", "Facility", new { id = model.NotificationId })); } } catch (ApiBadRequestException ex) { this.HandleBadRequest(ex); if (ModelState.IsValid) { throw; } } await this.BindCountryList(mediator, false); return(View(model)); }
public async Task<ActionResult> Index(Guid id, ImporterViewModel model) { if (!ModelState.IsValid) { return View(model); } var importer = new Importer(id) { Address = model.Address.AsAddress(), BusinessName = model.BusinessName, Type = model.Type, RegistrationNumber = model.RegistrationNumber, Contact = model.Contact.AsContact() }; await mediator.SendAsync(new SetDraftData<Importer>(id, importer)); return RedirectToAction("Index", "Producer"); }
public async Task <ActionResult> Index(Guid id, bool?backToOverview = null) { ImporterViewModel model; var importer = await mediator.SendAsync(new GetImporterByNotificationId(id)); if (importer.HasImporter) { model = new ImporterViewModel(importer); } else { model = new ImporterViewModel { NotificationId = id }; } await this.BindCountryList(mediator, false); model.Address.DefaultCountryId = this.GetDefaultCountryId(); return(View(model)); }
public async Task <ActionResult> Index(Guid id, ImporterViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var importer = new Importer(id) { Address = model.Address.AsAddress(), BusinessName = model.Business.Name, Type = model.BusinessType, RegistrationNumber = model.Business.RegistrationNumber, Contact = model.Contact.AsContact(), IsAddedToAddressBook = model.IsAddedToAddressBook }; await mediator.SendAsync(new SetDraftData <Importer>(id, importer)); return(RedirectToAction("Index", "Producer")); }
public ActionResult Save(string data) { Data parsedData = JsonConvert.DeserializeObject <Data>(data); ImportCustomers(parsedData); ImportCategories(parsedData); ImportSpecificationGroups(parsedData); ImportSpecifications(parsedData); ImportCompareGroups(parsedData); ImportCompareGroupSpecifications(parsedData); ImportBrands(parsedData); ImportItems(parsedData); ImportItemLinks(parsedData); ImportOrders(parsedData); UpdateCategoriesItemsCount(); var result = new ImporterViewModel(); result.Data = data; result.Error = ""; return(View("Index", data)); }
public ImporterBlock(IList<MergeField> mergeFields, Importer importer) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, "Importer"); data = new ImporterViewModel(importer); }
// GET: Importer public ActionResult Index() { var result = new ImporterViewModel(); return(View("Index", result)); }
public ImporterBlock(IList <MergeField> mergeFields, Importer importer) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, "Importer"); data = new ImporterViewModel(importer); }
public ImporterRowViewModel(ImporterViewModel parent) { Parent = parent; }