Exemplo n.º 1
0
 public IActionResult Import(ImportProjectDataViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (model.FromFile.Length > 0)
             {
                 if (!model.FromFile.FileName.EndsWith(".zip"))
                 {
                     throw new Exception("Csak .zip fájlok tölthetőek fel!");
                 }
                 System.IO.Directory.CreateDirectory($"{_env.WebRootPath}/images/projects/{model.ProjectId}");
                 string filePath = $"{_env.WebRootPath}/images/projects/{model.ProjectId}/export.zip";
                 using (var stream = System.IO.File.Create(filePath))
                 {
                     model.FromFile.CopyTo(stream);
                 }
                 EditorBL.ImportProjectFromZip(_context, model.ProjectId, $"{_env.WebRootPath}", filePath);
                 model.ImportSuccess = true;
             }
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex.Message);
         }
     }
     return(PartialView("ProjectImporter", model));
 }
Exemplo n.º 2
0
        public IActionResult ImportProject(int projectId)
        {
            ImportProjectDataViewModel model = new ImportProjectDataViewModel()
            {
                ProjectId = projectId
            };

            return(PartialView("ProjectImporter", model));
        }