ReportCards

This commit is contained in:
shadowik 2023-05-17 20:04:01 +04:00
parent 663f0122eb
commit 2244321365
9 changed files with 188 additions and 39 deletions

View File

@ -247,9 +247,56 @@ namespace BankYouBankruptClientApp.Controllers
return Redirect("~/Home/Enter");
}
return View(new ReportClientCardsViewModel() {
Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}")
});
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 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,
}) ;
}
}
}

View File

@ -15,14 +15,20 @@
<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">
@foreach (var item in Model.Cards)
<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">
<label class="form-check-label" for="flexSwitchCheckDefault">@item.Number</label>
<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">
@ -33,6 +39,9 @@
<th>
Номер карты
</th>
<th>
Тип операции
</th>
<th>
Сумма
</th>
@ -48,6 +57,29 @@
</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>

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

@ -8,10 +8,8 @@ namespace BankYouBankruptContracts.ViewModels
{
public class ReportClientCardsViewModel
{
public List<CardViewModel>? Cards { get; set; } = new();
public List<CheckboxViewModel>? Cards { get; set; } = new();
public List<DebitingViewModel>? Debitings { get; set; } = new();
public List<CreditingViewModel>? Creditings { 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
}
}