Exemplo n.º 1
0
        public IActionResult Create(int id, string name, string open)
        {
            var currentUserID = _userManager.GetUserId(User);

            if (string.IsNullOrWhiteSpace(name) ||
                !_filesService.IsNameUnique(id, name))
            {
                name = "NN.md";
            }
            var nodeID = _filesService.Create(name, id, currentUserID, "# " + name + "\n\n");

            if (open == "on" && nodeID > 0)
            {
                // If successfully created and user wanted to edit, then we open newly created file for editing.
                return(RedirectToAction("Editor", "Files", new { id = nodeID }));
            }
            else
            {
                // Back to project's file listing.
                if (nodeID > 0)
                {
                    return(RedirectToAction(nameof(FilesController.Index), "Files", new { id = id, msg = 1, hl = nodeID }));
                }
                else
                {
                    // Showing error.
                    return(RedirectToAction(nameof(FilesController.Index), "Files", new { id = id, msg = -1 }));
                }
            }
        }
Exemplo n.º 2
0
 public static void Main(string[] args) {
     
     //log4net.
     
     string var1 = "sugaaaar";
     var fs = new FilesService();
     fs.Create(var1);
     Console.WriteLine($"Can you give me {var1}");
 }   
Exemplo n.º 3
0
        public IActionResult Create(string name, bool template = false)
        {
            var currentUserID = _userManager.GetUserId(User);

            if (string.IsNullOrWhiteSpace(name))
            {
                name = "New Project";
            }
            var projectId = _projectsService.Create(name, currentUserID);

            var projectID = _filesService.Create("README.md", projectId, currentUserID, "# README\n\nWrite something nice here :)");

            if (projectID > 0)
            {
                return(RedirectToAction(nameof(ProjectsController.Index), "Projects", new { msg = 1, newID = projectID }));
            }
            else
            {
                return(RedirectToAction(nameof(ProjectsController.Index), "Projects", new { msg = -1 }));
            }
        }