public IActionResult RemoveDB(string filename) { if (RouteData != null) { _tenant = (Tenant)RouteData.Values.SingleOrDefault(r => r.Key == "tenant").Value; } var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot\\FileUploads" + "\\" + _tenant.HostName, filename); FileInfo fileInfo = new FileInfo(path); using (ExcelPackage package = new ExcelPackage(fileInfo)) { int workSheetTotal = package.Workbook.Worksheets.Count; try { List <string> OrderNumberList = new List <string>(); for (int j = 1; j <= workSheetTotal; j++) { ExcelWorksheet workSheet = package.Workbook.Worksheets[j]; if (workSheet.Dimension != null) { int totalRows = workSheet.Dimension.Rows; for (int i = 2; i <= totalRows; i++) { OrderNumberList.Add(AssignCell(i, workSheet, "Order number")); } } } _inspectionRepository.DeleteInspectByOrderNumbers(OrderNumberList); } catch (Exception ex) { throw ex; } return(RedirectToAction("Index")); } }