public async Task <IActionResult> Put(int id, [FromBody] FolderContent value) { var oldFolder = await _context.CloudFolders.FirstOrDefaultAsync(p => p.FolderId == id); if (oldFolder == null) { return(NotFound("File not found")); } oldFolder.Name = value.Name; oldFolder.ParentFolderId = value.ParentFolderId; try { _context.CloudFolders.Update(oldFolder); await _context.SaveChangesAsync(); return(Ok(oldFolder)); } catch (Exception e) { return(BadRequest(e)); } }
public async Task <IActionResult> Post([FromBody] FolderContent value) { var checkFolder = await _context.CloudFolders.FirstOrDefaultAsync(p => p.ParentFolderId == value.ParentFolderId && p.Name == value.Name); if (checkFolder != null) { return(BadRequest("Folder Already Exists in this directory")); } var entity = new Folder { ParentFolderId = value.ParentFolderId, Name = value.Name, TruePath = value.Path }; await _context.CloudFolders.AddAsync(entity); await _context.SaveChangesAsync(); return(Ok(entity)); }