diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 6726751..86c6749 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -88,53 +88,100 @@ namespace BankBusinessLogic.OfficePackage MergeCells(new ExcelMergeParameters { CellFromName = "A1", - CellToName = "C1" + CellToName = "F1" }); - uint rowIndex = 2; - foreach (var transfer in info.Transfers) + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "A", + RowIndex = 2, + Text = "Номер карты", + StyleInfo = ExcelStyleInfoType.Title + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "B", + RowIndex = 2, + Text = "Номер перевода", + StyleInfo = ExcelStyleInfoType.Title + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "C", + RowIndex = 2, + Text = "Сумма", + StyleInfo = ExcelStyleInfoType.Title + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "D", + RowIndex = 2, + Text = "Время перевода", + StyleInfo = ExcelStyleInfoType.Title + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "E", + RowIndex = 2, + Text = "Счет отправителя", + StyleInfo = ExcelStyleInfoType.Title + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "F", + RowIndex = 2, + Text = "Счет получателя", + StyleInfo = ExcelStyleInfoType.Title + }); + uint rowIndex = 3; + foreach (var report in info.Transfers) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "A", RowIndex = rowIndex, - Text = "", + Text = report.CardNumber, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var transfer1 in transfer.Transfers) + foreach (var transfer in report.Transfers) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = "", + Text = transfer.Id.ToString(), StyleInfo = ExcelStyleInfoType.TextWithBroder }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "C", RowIndex = rowIndex, - Text = "", - StyleInfo = - ExcelStyleInfoType.TextWithBroder + Text = transfer.Sum.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "D", + RowIndex = rowIndex, + Text = transfer.TransferTime.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "E", + RowIndex = rowIndex, + Text = transfer.SenderAccountNumber, + StyleInfo = ExcelStyleInfoType.TextWithBroder + }); + InsertCellInWorksheet(new ExcelCellParameters + { + ColumnName = "F", + RowIndex = rowIndex, + Text = transfer.RecipientAccountNumber, + StyleInfo = ExcelStyleInfoType.TextWithBroder }); rowIndex++; } - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "A", - RowIndex = rowIndex, - Text = "Итого", - StyleInfo = ExcelStyleInfoType.Text - }); - InsertCellInWorksheet(new ExcelCellParameters - { - ColumnName = "C", - RowIndex = rowIndex, - Text = "", - StyleInfo = ExcelStyleInfoType.Text - }); - rowIndex++; } SaveExcel(info); } diff --git a/Bank/BankClientApp/Controllers/HomeController.cs b/Bank/BankClientApp/Controllers/HomeController.cs index 34411ca..8c5b290 100644 --- a/Bank/BankClientApp/Controllers/HomeController.cs +++ b/Bank/BankClientApp/Controllers/HomeController.cs @@ -531,7 +531,7 @@ namespace BankClientApp.Controllers case "excel": APIClient.PostRequest($"api/report/savetransferstoexcel", new ReportBindingModel { - FileName = "C:\\Users\\123\\Desktop\\excelfile.xls", + FileName = "C:\\Users\\123\\Desktop\\excelfile.xlsx", SelectedCardIds = cards, }); break; diff --git a/Bank/BankClientApp/Views/Home/OperationTransfer.cshtml b/Bank/BankClientApp/Views/Home/OperationTransfer.cshtml index 17003c9..a1ade22 100644 --- a/Bank/BankClientApp/Views/Home/OperationTransfer.cshtml +++ b/Bank/BankClientApp/Views/Home/OperationTransfer.cshtml @@ -18,110 +18,8 @@ -
-

Перевод

-
-
-
Сумма:
-
- -
-
-
-
Номер счета отправителя:
-
- -
-
-
-
Номер счета получателя:
-
- -
-
-
-
Дата:
-
- -
-
- -
-

Операция

-
-
-
Сумма:
-
- -
-
-
-
Отправитель:
-
- -
-
-
-
Получатель:
-
- -
-
-
-
Дата:
-
- -
-
-
- - -@section Scripts - { - -} \ No newline at end of file + \ No newline at end of file diff --git a/Bank/BankDatabaseImplement/Implements/OperationStorage.cs b/Bank/BankDatabaseImplement/Implements/OperationStorage.cs index 9c4a430..5abc0f5 100644 --- a/Bank/BankDatabaseImplement/Implements/OperationStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/OperationStorage.cs @@ -58,7 +58,7 @@ namespace BankDatabaseImplement.Implements var transfer = context.Transfers.FirstOrDefault(x => x.OperationId == model.Id); if (transfer != null) { - return null; + throw new InvalidOperationException("Обновление невозможно"); } if (operation == null) { @@ -75,7 +75,7 @@ namespace BankDatabaseImplement.Implements var transfer = context.Transfers.FirstOrDefault(x => x.OperationId == model.Id); if (transfer != null) { - return null; + throw new InvalidOperationException("Удаление невозможно"); } if (operation != null) { diff --git a/Bank/BankDatabaseImplement/Implements/RequestStorage.cs b/Bank/BankDatabaseImplement/Implements/RequestStorage.cs index 086bae4..3a9dbd8 100644 --- a/Bank/BankDatabaseImplement/Implements/RequestStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/RequestStorage.cs @@ -99,7 +99,7 @@ namespace BankDatabaseImplement.Implements .FirstOrDefault(rec => rec.Id == model.Id); if (element?.Status != RequestStatus.Принята) { - return null; + throw new InvalidOperationException("Заявка уже выполнена"); } if (element != null) { diff --git a/Bank/BankRestApi/Controllers/ReportController.cs b/Bank/BankRestApi/Controllers/ReportController.cs index 495a3e4..e528fe5 100644 --- a/Bank/BankRestApi/Controllers/ReportController.cs +++ b/Bank/BankRestApi/Controllers/ReportController.cs @@ -49,9 +49,17 @@ namespace BankRestApi.Controllers } } [HttpPost] - public void SaveTransfersToExcel(ReportBindingModel? model) + public void SaveTransfersToExcel(ReportBindingModel model) { - + try + { + _logic.SaveTransfersToExcelFile(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения переводов в ворд"); + throw; + } } } }