示例#1
0
        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));
            }
        }
示例#2
0
        public IActionResult GetById(long id)
        {
            var folder = _folderRepository.Find(id);

            return(new ObjectResult(folder));
        }