private void LoadDefaultFileMapConfig(ClientDependencySection section, HttpContextBase http) { if (section.CompositeFileElement.FileMapProviders.Count == 0) { //if not specified, create default var fmp = new XmlFileMapper(); fmp.Initialize(XmlFileMapper.DefaultName, null); fmp.Initialize(http); FileMapProviderCollection.Add(fmp); } else { ProvidersHelper.InstantiateProviders(section.CompositeFileElement.FileMapProviders, FileMapProviderCollection, typeof(BaseFileMapProvider)); //since the BaseFileMapProvider is an IHttpProvider, we need to do the http init foreach (var p in FileMapProviderCollection.Cast <BaseFileMapProvider>()) { p.Initialize(http); } } }
public async Task <IActionResult> Create(XmlFileAddViewModel xmlFileAddViewModel) { if (ModelState.IsValid) { //Convert to xmlfiile model with mapper, then save the model to db XmlFile xmlFile = await XmlFileMapper.MapFromXmlFileAddViewModelAsync(xmlFileAddViewModel); if (xmlFile.PreviousFileId != null) { xmlFile.PreviousSignedFile = await _context.XmlFiles.FindAsync(xmlFile.PreviousFileId); } xmlFile.Signer = await _userManager.GetUserAsync(User); _context.XmlFiles.Add(xmlFile); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PreviousFileId"] = new SelectList(_context.XmlFiles, "Id", "FileContent", xmlFileAddViewModel.PreviousFileId); return(View(xmlFileAddViewModel)); }