Esempio n. 1
0
        public async Task <IActionResult> GetInfoAsync(string id)
        {
            var share = await _shareService.GetShareByIdAsync(id);

            if (share == null)
            {
                return(NotFound());
            }
            var user = await _userService.GetUserByIdAsync(share.UserId);

            var sharedObjectsList = await _shareService.GetShareContentAsync(share);

            var fsoList = await _fsoService.GetFsoListByIdAsync(sharedObjectsList.Select(x => x.FsoId).ToArray());

            var totalSize    = (long)0;
            var filesCount   = 0;
            var foldersCount = 0;

            foreach (var fso in fsoList)
            {
                totalSize += await _fsoService.GetFsoSizeByIdAsync(fso.Id);

                if (fso.IsFolder)
                {
                    foldersCount++;
                }
                else
                {
                    filesCount++;
                }
            }
            return(Ok(new { user.Username, share.ShareDate, foldersCount, filesCount, totalSize }));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetUserDiskInfo()
        {
            var user = await _userService.GetUserFromPrincipalAsync(this.User);

            if (user == null)
            {
                return(Unauthorized());
            }
            else
            {
                var usedBytes = await _fsoService.GetFsoSizeByIdAsync((int)user.DriveId);

                var totalBytes = long.Parse(_storageSize);
                var diskUsed   = Math.Round(usedBytes * 100.0 / totalBytes);
                return(Ok(new { usedBytes = usedBytes.ToString(), totalBytes = totalBytes.ToString(), diskUsed = diskUsed.ToString() }));
            }
        }