diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index ce74f09..21b02d9 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -142,7 +142,6 @@ namespace BankYouBankruptClientApp.Controllers #endregion - #region Снятие средств [HttpGet] @@ -245,15 +244,81 @@ namespace BankYouBankruptClientApp.Controllers [HttpGet] public IActionResult CreateReport() { - return View(); + + [HttpGet] + public IActionResult ReportWithCards() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + + return View(new ReportClientCardsViewModel() + { + Cards = APIClient.GetRequest>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}").Select(x => new CheckboxViewModel() { + Id = x.Id, + LabelName = x.Number, + IsChecked = false + }).ToList() + }) ; } [HttpPost] - public void CreateReport(DateTime DateFrom, DateTime DateTo) + public IActionResult ReportWithCards(List cards) { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + List cardList = cards.Where(x => x.IsChecked).Select(x => x.Id).ToList(); + List creditings = APIClient.GetRequest>($"api/Client/getUsersCreditings?userId={APIClient.Client.Id}") + .Where(x => cardList.Contains(x.CardId)).Select(x => new ReportViewModel() { + Id=x.Id, + CardId=x.CardId, + DateOpen=x.DateOpen, + DateClose=x.DateClose, + CardNumber=x.CardNumber, + Status = x.Status, + Sum = x.Sum, + TypeOperation = TypeOperationEnum.Пополнение + }).ToList(); + List debitings = APIClient.GetRequest>($"api/Client/getUsersDebitings?userId={APIClient.Client.Id}") + .Where(x => cardList.Contains(x.CardId)).Select(x => new ReportViewModel() + { + Id = x.Id, + CardId = x.CardId, + DateOpen = x.DateOpen, + DateClose = x.DateClose, + CardNumber = x.CardNumber, + Status = x.Status, + Sum = x.Sum, + TypeOperation = TypeOperationEnum.Снятие + }).ToList(); + List result = creditings.Concat(debitings).OrderBy(x => x.DateOpen).ToList(); + + return View(new ReportClientCardsViewModel() + { + Cards = cards, + Operations = result, + + }) ; } - #endregion - } -} \ No newline at end of file + #region Получение отчёта + + [HttpGet] + public IActionResult CreateReport() + { + return View(); + } + + [HttpPost] + public void CreateReport(DateTime DateFrom, DateTime DateTo) + { + + } + + #endregion + } + } \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/ReportWithCards.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/ReportWithCards.cshtml new file mode 100644 index 0000000..5be8d19 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/ReportWithCards.cshtml @@ -0,0 +1,88 @@ +@using BankYouBankruptContracts.ViewModels + +@model ReportClientCardsViewModel + +@{ + ViewData["Title"] = "Отчет по картам"; +} + +
+

Отчет

+
+ +
+ +
+
+
+
+ @for (var item = 0; item < @Model.Cards.Count(); item++) + { +
+ + + + +
+ } +
+ +
+
+
+
+
+
+ + + + + + + + + + + + + @foreach (var item in Model.Operations) + { + + + + + + + + + } + +
+ Номер карты + + Тип операции + + Сумма + + Статус + + Дата открытия + + Дата закрытия +
+ @Html.DisplayFor(modelItem => item.CardNumber) + + @Html.DisplayFor(modelItem => item.TypeOperation) + + @Html.DisplayFor(modelItem => item.Sum) + + @Html.DisplayFor(modelItem => item.Status) + + @Html.DisplayFor(modelItem => item.DateOpen) + + @Html.DisplayFor(modelItem => item.DateClose) +
+
+
+
+
\ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml index 1e0ccf2..cfd83bd 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml @@ -24,21 +24,24 @@ diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CheckboxViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CheckboxViewModel.cs new file mode 100644 index 0000000..a336b18 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CheckboxViewModel.cs @@ -0,0 +1,17 @@ +using BankYouBankruptDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptContracts.ViewModels +{ + public class CheckboxViewModel + { + public int Id { get; set; } + public string LabelName { get; set; } + public bool IsChecked { get; set; } + } +} diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel.cs similarity index 100% rename from BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs rename to BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel.cs diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportCardViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportCardViewModel.cs new file mode 100644 index 0000000..57ce51b --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportCardViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptContracts.ViewModels +{ + internal class ReportCardViewModel + { + } +} diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportClientCardsViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportClientCardsViewModel.cs new file mode 100644 index 0000000..7d92f4d --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportClientCardsViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptContracts.ViewModels +{ + public class ReportClientCardsViewModel + { + public List? Cards { get; set; } = new(); + + public List? Operations { get; set; } = new(); + } +} diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportClientViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportClientViewModel.cs index 9d31d90..b174270 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportClientViewModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportClientViewModel.cs @@ -14,4 +14,4 @@ namespace BankYouBankruptContracts.ViewModels public DateTime? DateComplite { get; set; } } -} +} \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportViewModel.cs new file mode 100644 index 0000000..d1b7a28 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ReportViewModel.cs @@ -0,0 +1,29 @@ +using BankYouBankruptDataModels.Enums; +using BankYouBankruptDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptContracts.ViewModels +{ + public class ReportViewModel + { + public int Id { get; set; } + + public int CardId { get; set; } + + public string? CardNumber { get; set; } + + public int Sum { get; set; } + + public DateTime DateOpen { get; set; } + + public DateTime? DateClose { get; set; } + + public StatusEnum Status { get; set; } + + public TypeOperationEnum TypeOperation { get; set; } + } +} diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Enums/TypeOperationEnum.cs b/BankYouBankrupt/BankYouBankruptDataModels/Enums/TypeOperationEnum.cs new file mode 100644 index 0000000..1356e76 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptDataModels/Enums/TypeOperationEnum.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptDataModels.Enums +{ + public enum TypeOperationEnum + { + Снятие = 1, + Пополнение = 2 + } +}