public FolderViewModel CreateFolder(FolderViewModel folder) { var folderEntity = new Folder { ParentFolderId = folder.ParentId, Name = folder.Name }; _folderRepository.Create(folderEntity); return(new FolderViewModel { Id = folderEntity.Id, ParentId = folderEntity.ParentFolderId, Name = folderEntity.Name, Folders = new List <FolderViewModel>() }); }
public IActionResult CreateFolder(ApiFolder apiFolder) { if (!ModelState.IsValid) { return(BadRequest()); } var folder = (Folder)apiFolder; var folderDb = _folderRepository.Create(folder); if (!folderDb) { return(BadRequest()); } return(Ok(folderDb)); }
public IActionResult Create([FromBody] Project project) { if (project == null) { return(BadRequest()); } var userId = _userManager.GetUserId(HttpContext.User); _projectRepository.Add(project); _collaboratorRepository.Create(userId, project.Id, Permissions.Owner); Folder folder = _folderRepository.Create("src", null, project.Id); _fileRepository.Create(folder.Id, Syntax.JavaScript, "index.js", "console.log('hello world');"); var newProject = _projectRepository.Find(project.Id); return(CreatedAtRoute("GetProject", new { id = project.Id }, newProject)); }