Правки отчёта Клиента.

This commit is contained in:
Programmist73 2023-05-19 18:06:21 +04:00
parent 0b7e8c20d2
commit 661f6ffad5
9 changed files with 41 additions and 37 deletions

View File

@ -71,16 +71,30 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
public List<MoneyTransferViewModel>? GetMoneyTransfer(ReportBindingModel model)
{
var accountId = _cardStorage.GetElement(new CardSearchModel
{
Id = model.CardId
}).AccountId;
//список счетов по выбранным картам
List<int> accountId = new();
return _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel
foreach(var index in model.CardList)
{
AccountPayeeId = accountId,
AccountSenderId = accountId
});
accountId.Add(_cardStorage.GetElement(new CardSearchModel { Id = index}).AccountId);
}
var list = accountId.ToHashSet().ToList();
List<MoneyTransferViewModel> totalList = new();
foreach (var index in list)
{
var result = _moneyTransferStorage.GetFilteredList(new MoneyTransferSearchModel
{
AccountSenderId = index,
AccountPayeeId = index
}).OrderBy(x => x.AccountSenderId).ToList();
totalList.Union(result);
}
return totalList;
}
public void SaveToExcelFile(ReportBindingModel model)

View File

@ -272,37 +272,20 @@ namespace BankYouBankruptClientApp.Controllers
#region Excel отчёт
[HttpGet]
public IActionResult CreateExcelReport()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}");
return View();
}
[HttpPost]
public IActionResult CreateExcelReport(int cardId)
public void CreateExcelReport(List<CheckboxViewModel> cards)
{
if (APIClient.Client == null)
{
throw new Exception("Не авторизованы");
}
//ViewBag.DataOfClientReport = APIClient.GetRequest<ReportClientViewModelForHTML>($"api/Report/GetDataOfClientReport");
APIClient.PostRequest("api/Report/CreateExcelClient", new ReportSupportBindingModel()
{
CardId = cardId
CardList = cards.Where(x => x.IsChecked).Select(x => x.Id).ToList()
});
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}");
return View();
}
#endregion

View File

@ -28,6 +28,9 @@
<div>
<input class="btn btn-primary mt-3" type="submit" value="Submit" />
</div>
<div>
<button class="btn btn-lg btn-primary btn-block" type="submit" asp-controller="Home" asp-action="CreateExcelReport">Создать отчёт Excel</button>
</div>
</form>
</div>
</div>

View File

@ -1,4 +1,5 @@
using System;
using BankYouBankruptContracts.ViewModels.Client.Reports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -12,7 +13,7 @@ namespace BankYouBankruptContracts.BindingModels
public int? ClientId { get; set; }
public int? CardId { get; set; }
public List<int>? CardList { get; set; }
public string? ClientFullName { get; set; } = string.Empty;

View File

@ -1,4 +1,5 @@
using System;
using BankYouBankruptContracts.ViewModels.Client.Reports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -16,6 +17,6 @@ namespace BankYouBankruptContracts.BindingModels
public DateTime DateTo { get; set; }
//для Excel отчёта клиента
public int? CardId { get; set; }
public List<int>? CardList { get; set; }
}
}

View File

@ -11,7 +11,9 @@ namespace BankYouBankruptContracts.ViewModels.Client.Reports
public class CheckboxViewModel
{
public int Id { get; set; }
public string LabelName { get; set; }
public bool IsChecked { get; set; }
}
}

View File

@ -35,16 +35,16 @@ namespace BankYouBankruptDatabaseImplement.Implements
.Include(x => x.AccountSender)
.ToList();
if(model.AccountPayeeId.HasValue && model.AccountSenderId.HasValue && model.AccountPayeeId == model.AccountSenderId)
if (model.AccountPayeeId.HasValue && model.AccountSenderId.HasValue && model.AccountPayeeId == model.AccountSenderId)
{
return result.Where(x => (x.AccountSenderId == model.AccountSenderId || x.AccountPayeeId == model.AccountPayeeId)
return result.Where(x => (x.AccountSenderId == model.AccountSenderId || x.AccountPayeeId == model.AccountPayeeId)
&& x.AccountSender != null)
.ToList()
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
}
if (model.AccountPayeeId.HasValue) result = result.Where(x => x.AccountPayeeId == model.AccountPayeeId).ToList();
if (model.AccountPayeeId.HasValue) result = result.Where(x => x.AccountPayeeId == model.AccountPayeeId).ToList();
if (model.AccountSenderId.HasValue) result = result.Where(x => x.AccountSenderId == model.AccountSenderId).ToList();

View File

@ -88,7 +88,7 @@ namespace BankYouBankruptRestAPI.Controllers
_reportClientLogic.SaveToExcelFile(new ReportBindingModel
{
FileName = "Отчёт_по_переводам",
CardId = model.CardId
CardList = model.CardList
});
}
catch (Exception ex)