This commit is contained in:
Programmist73 2023-05-18 00:08:30 +04:00
commit 076b27ba7d
10 changed files with 265 additions and 22 deletions

View File

@ -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<List<CardViewModel>>($"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<CheckboxViewModel> cards)
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
List<int> cardList = cards.Where(x => x.IsChecked).Select(x => x.Id).ToList();
List<ReportViewModel> creditings = APIClient.GetRequest<List<CreditingViewModel>>($"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<ReportViewModel> debitings = APIClient.GetRequest<List<DebitingViewModel>>($"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<ReportViewModel> result = creditings.Concat(debitings).OrderBy(x => x.DateOpen).ToList();
return View(new ReportClientCardsViewModel()
{
Cards = cards,
Operations = result,
}) ;
}
#endregion
#region Получение отчёта
[HttpGet]
public IActionResult CreateReport()
{
return View();
}
[HttpPost]
public void CreateReport(DateTime DateFrom, DateTime DateTo)
{
}
#endregion
}
}
}

View File

@ -0,0 +1,88 @@
@using BankYouBankruptContracts.ViewModels
@model ReportClientCardsViewModel
@{
ViewData["Title"] = "Отчет по картам";
}
<div class="text-center">
<h1 class="display-4">Отчет</h1>
</div>
<div class="container" sf-type="container" sf-label="Bootstrap Container" sf-uid="2">
<div class="row" sf-type="container" sf-label="Row" sf-uid="3">
<div class="mb-4 mb-md-0 aos-init aos-animate col-md-3" sf-type="container" sf-label="Column" sf-anim-delay="1.5" data-aos="fade-down" data-aos-delay="400" sf-uid="4">
<div sf-type="container" sf-label="Container" class="py-15 h-100 bg-bg-2" sf-uid="5">
<form method="post">
@for (var item = 0; item < @Model.Cards.Count(); item++)
{
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="flexSwitchCheckDefault" asp-for="@Model.Cards[item].IsChecked">
<label class="form-check-label" for="flexSwitchCheckDefault">@Model.Cards[item].LabelName</label>
<input type="hidden" asp-for="@Model.Cards[item].Id" />
<input type="hidden" asp-for="@Model.Cards[item].LabelName" />
</div>
}
<div>
<input class="btn btn-primary mt-3" type="submit" value="Submit" />
</div>
</form>
</div>
</div>
<div class="aos-init aos-animate col-md" sf-type="container" sf-label="Column" sf-anim-delay="2" data-aos="fade-down" data-aos-delay="500" sf-uid="8">
<div sf-type="container" sf-label="Container" class="py-15 h-100 bg-bg-2" sf-uid="9">
<table class="table">
<thead>
<tr>
<th>
Номер карты
</th>
<th>
Тип операции
</th>
<th>
Сумма
</th>
<th>
Статус
</th>
<th>
Дата открытия
</th>
<th>
Дата закрытия
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Operations)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.CardNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.TypeOperation)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sum)
</td>
<td>
@Html.DisplayFor(modelItem => item.Status)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOpen)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateClose)
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@ -24,21 +24,24 @@
</a>
<div class="navbar-collapse collapse d-sm-inline-flex flex-smrow-reverse">
@{ if (authenticated) {
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CardsList">Карты</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="DebitingList">Снятие средств</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreditingList">Пополнить средства</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreateReport">Отчёт по картам</a>
</li>
</ul>
}
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CardsList">Карты</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="DebitingList">Снятие средств</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreditingList">Пополнить средства</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ReportWithCards">Отчет по картам</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreateReport">Отчёт по картам</a>
</li>
</ul>
}
}
</div>
</div>

View File

@ -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; }
}
}

View File

@ -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
{
}
}

View File

@ -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<CheckboxViewModel>? Cards { get; set; } = new();
public List<ReportViewModel>? Operations { get; set; } = new();
}
}

View File

@ -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; }
}
}

View File

@ -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
}
}