Example #1
0
        public async Task <string> ClearSheet()
        {
            Response.Headers.Add("Cache-Control", "no-cache");
            string    response       = string.Empty;
            string    imagesFolderId = null;
            string    accountName    = this._httpContextAccessor.HttpContext.Request.Headers[DriveImportConstants.VTEX_ACCOUNT_HEADER_NAME];
            FolderIds folderIds      = await _driveImportRepository.LoadFolderIds(accountName);

            if (folderIds != null)
            {
                imagesFolderId = folderIds.ImagesFolderId;
                ListFilesResponse spreadsheets = await _googleDriveService.ListSheetsInFolder(imagesFolderId);

                if (spreadsheets != null)
                {
                    SheetRange sheetRange = new SheetRange();
                    sheetRange.Ranges = new List <string>();
                    sheetRange.Ranges.Add($"A2:Z{DriveImportConstants.DEFAULT_SHEET_SIZE}");

                    foreach (GoogleFile sheet in spreadsheets.Files)
                    {
                        response = response + " - " + _googleDriveService.ClearSpreadsheet(sheet.Id, sheetRange).Result;
                    }
                }
                else
                {
                    response = "null sheet";
                }
            }
            else
            {
                response = "null folderIds";
            }

            return(response);
        }