Example #1
0
        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));
        }