示例#1
0
        public ActionResult Save(ListFileViewModel model)
        {
            if (model.Content != null)
            {
                byte[] array = Encoding.ASCII.GetBytes(model.Content);
                fileService.SaveFile(array, model.FileId);
            }
            else
            {
                byte[] array = new byte[0];
                fileService.SaveFile(array, model.FileId);
            }

            return(RedirectToAction("OpenEditor", "Project", new { id = model.ProjectId, code = model.Content, fileID = model.FileId }));
        }
示例#2
0
        public ActionResult OpenEditor(int?id, string code, int?fileID)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }
            // Checks if the user has access to the project.
            if (!service.HasAccess(Convert.ToInt32(id)))
            {
                throw new Exception("Project is Empty or no access");
            }
            ListFileViewModel model      = new ListFileViewModel();
            ThemeViewModel    themeModel = new ThemeViewModel();

            model.AllFiles = service.GetAllFiles(Convert.ToInt32(id));

            if (model.AllFiles.Count == 0)
            {
                return(RedirectToAction("CreateFile", new { id = id }));
            }
            if (fileID == null)
            {
                // Redirects to get first file to display.
                return(RedirectToAction("DisplayFile", new { id = model.AllFiles.First().ID, projectID = id }));
            }

            ViewBag.ProjectName = service.GetProjectName(Convert.ToInt32(id));
            model.ProjectId     = Convert.ToInt32(id);
            model.Content       = code;
            model.ProjectId     = Convert.ToInt32(id);
            model.FileId        = Convert.ToInt32(fileID);
            model.Filetype      = fileService.GetFileTypeName(Convert.ToInt32(fileID));
            model.Theme         = themeService.CallTheme();
            model.Users         = service.UserListofSharedProject(Convert.ToInt32(id));
            return(View(model));
        }
示例#3
0
        public ActionResult DeleteFile(ListFileViewModel model)
        {
            fileService.DeleteFile(model.FileId);

            return(RedirectToAction("OpenEditor", "Project", new { id = model.ProjectId }));
        }