public async Task <IActionResult> Create([FromBody] File item) { if (item == null) { return(BadRequest()); } var parent = _folderRepository.Find(item.ParentID); if (parent == null) { return(BadRequest()); } var userId = _userManager.GetUserId(HttpContext.User); if (!_permissionServices.HasWriteAccess(parent.ProjectID, userId)) { return(Unauthorized()); } else { _fileRepository.Add(item); await _fileHandler.Add(item.Id, item.Name, item.Content, item.Syntax, item.ParentID, parent.ProjectID); return(CreatedAtAction("GetFile", new { id = item.Id }, item)); } }
public IActionResult GetById(long id) { var folder = _folderRepository.Find(id); return(new ObjectResult(folder)); }