public IActionResult Save(ProjectViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (model.ProjectId == 0)
             {
                 if (model.OwnerId <= 0)
                 {
                     model.OwnerId = int.Parse(_userManager.GetUserId(User));
                 }
                 model = ProjectsBL.CreateProject(_context, model);
             }
             else
             {
                 model = ProjectsBL.EditProjectData(_context, model);
             }
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex.Message);
         }
     }
     return(PartialView("CreateEdit", model));
 }
Exemple #2
0
        public async Task <IActionResult> Export(int projectId, bool jsonExport = true)
        {
            EditorViewModel model = EditorBL.EditorData(_context, projectId, $"{_env.WebRootPath}");

            model.Mode = EditorMode.Export;

            if (model.ProjectData == null)
            {
                return(RedirectToAction("Index", "Projects"));
            }

            string redirect = "";

            if (jsonExport)
            {
                redirect = EditorBL.ExportProjectJson(_context, projectId, $"{_env.WebRootPath}");
            }
            else
            {
                string htmlContent = await RenderPartialViewToString("Preview", model);

                redirect = EditorBL.ExportProjectHtml(projectId, $"{_env.WebRootPath}", htmlContent, model.EditorData.CustomCss);
            }

            ProjectsBL.SetProjectStatus(_context, projectId, Models.Enums.ProjectStatus.Exported, true);

            return(RedirectToAction("Index", "Projects", new { RedirectTo = redirect }));
        }
        public IActionResult ReloadContent(bool ShowAllProject)
        {
            int  userId  = int.Parse(_userManager.GetUserId(User));
            bool isAdmin = UsersBL.UserIsAdmin(_context, userId);
            ProjectListViewModel model = ProjectsBL.ProjectListModel(_context, isAdmin, ShowAllProject, userId);

            return(PartialView("Content", model.ProjectList));
        }
        public async Task <IActionResult> Index(bool ShowAllProject = false, string RedirectTo = "")
        {
            IList <User> users = await _userManager.GetUsersInRoleAsync("Admin");

            int  userId  = int.Parse(_userManager.GetUserId(User));
            bool isAdmin = users.Where(x => x.Id == userId).Count() != 0;

            ShowAllProject = ShowAllProject && isAdmin;
            return(View(ProjectsBL.ProjectListModel(_context, isAdmin, ShowAllProject, userId, RedirectTo)));
        }
Exemple #5
0
        public IActionResult Index(int projectId)
        {
            EditorViewModel editor = EditorBL.EditorData(_context, projectId, $"{_env.WebRootPath}");

            if (editor.ProjectData == null)
            {
                return(RedirectToAction("Index", "Projects"));
            }
            ProjectsBL.SetProjectStatus(_context, projectId, Models.Enums.ProjectStatus.Editable);
            return(View(editor));
        }
 public JsonResult DeleteProject(int projectId)
 {
     try
     {
         int userId = int.Parse(_userManager.GetUserId(User));
         ProjectsBL.DeleteProject(_context, projectId, userId);
         string filePath = $"{_env.WebRootPath}/images/projects/{projectId}.jpg";
         if (System.IO.File.Exists(filePath))
         {
             System.IO.File.Delete(filePath);
         }
         filePath = $"{_env.WebRootPath}/images/projects/{projectId}";
         if (System.IO.Directory.Exists(filePath))
         {
             System.IO.Directory.Delete(filePath);
         }
         return(Json("SUCCESS"));
     }
     catch (Exception ex)
     {
         return(Json(ex.Message));
     }
 }
        public IActionResult Edit(int projectId)
        {
            ProjectViewModel project = ProjectsBL.GetProjectData(_context, projectId);

            return(PartialView("CreateEdit", project));
        }