Прикол

This commit is contained in:
Programmist73 2023-05-18 21:58:16 +04:00
commit b8554342d2
51 changed files with 308 additions and 109 deletions

View File

@ -3,12 +3,15 @@ using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.BusinessLogicsContracts;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptContracts.ViewModels.Client.Diagram;
using BankYouBankruptDataModels.Enums;
using DocumentFormat.OpenXml.Drawing;
namespace BankYouBankruptBusinessLogic.BusinessLogics namespace BankYouBankruptBusinessLogic.BusinessLogics
{ {
@ -17,11 +20,16 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ICardStorage _cardStorage; private readonly ICardStorage _cardStorage;
private readonly IAccountStorage _accountStorage; private readonly IAccountStorage _accountStorage;
private readonly IDebitingLogic _debitingLogic;
private readonly ICreditingLogic _creditingLogic;
public CardLogic(ILogger<CardLogic> logger, ICardStorage cardStorage, IAccountStorage accountStorage) { public CardLogic(ILogger<CardLogic> logger, ICardStorage cardStorage, IAccountStorage accountStorage,
IDebitingLogic debitingLogic, ICreditingLogic creditingLogic) {
_logger = logger; _logger = logger;
_cardStorage = cardStorage; _cardStorage = cardStorage;
_accountStorage = accountStorage; _accountStorage = accountStorage;
_debitingLogic = debitingLogic;
_creditingLogic = creditingLogic;
} }
public bool Create(CardBindingModel model) public bool Create(CardBindingModel model)
@ -88,6 +96,31 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
return true; return true;
} }
public List<ClientDiagramElementsViewModel> GetMonthInfo(int CardId) {
Dictionary<(int?, int?), int> debitings = _debitingLogic.ReadList(new DebitingSearchModel()
{
CardId = CardId,
Status = StatusEnum.Закрыта
}).GroupBy(x => new { x.DateClose?.Month, x.DateClose?.Year })
.Select(x => new { x.Key.Month, x.Key.Year, Sum = x.Select(y => y.Sum).Sum()}).ToDictionary(x => (x.Month, x.Year), x => (x.Sum));
Dictionary<(int?, int?), int> creditings = _creditingLogic.ReadList(new CreditingSearchModel()
{
CardId = CardId,
Status = StatusEnum.Закрыта
}).GroupBy(x => new { x.DateClose?.Month, x.DateClose?.Year })
.Select(x => new { x.Key.Month, x.Key.Year, Sum = x.Select(y => y.Sum).Sum() }).ToDictionary(x => (x.Month, x.Year), x => (x.Sum));
List<ClientDiagramElementsViewModel> result = new();
foreach (var key in debitings.Keys.Union(creditings.Keys)) {
int sum = 0;
if (debitings.ContainsKey(key)) sum -= debitings.GetValueOrDefault(key);
if (creditings.ContainsKey(key)) sum += creditings.GetValueOrDefault(key);
result.Add(new ClientDiagramElementsViewModel() { Name = Enum.GetName(typeof(Months), key.Item1) + " " + key.Item2.ToString(), Value = sum});
}
return result;
}
private void CheckModel(CardBindingModel model, bool withParams = true) private void CheckModel(CardBindingModel model, bool withParams = true)
{ {
if (model == null) if (model == null)

View File

@ -3,12 +3,12 @@ using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.BusinessLogicsContracts;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BankYouBankruptContracts.ViewModels.Client.Default;
namespace BankYouBankruptBusinessLogic.BusinessLogics namespace BankYouBankruptBusinessLogic.BusinessLogics
{ {

View File

@ -3,12 +3,12 @@ using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.BusinessLogicsContracts;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BankYouBankruptContracts.ViewModels.Client.Default;
namespace BankYouBankruptBusinessLogic.BusinessLogics namespace BankYouBankruptBusinessLogic.BusinessLogics
{ {
@ -16,14 +16,10 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ICreditingStorage _creditingStorage; private readonly ICreditingStorage _creditingStorage;
private readonly ICardLogic _cardLogic;
private readonly IAccountLogic _accountLogic;
public CreditingLogic(ILogger<CreditingLogic> logger, ICreditingStorage creditingStorage, ICardLogic cardLogic, IAccountLogic accountLogic) { public CreditingLogic(ILogger<CreditingLogic> logger, ICreditingStorage creditingStorage) {
_logger = logger; _logger = logger;
_creditingStorage = creditingStorage; _creditingStorage = creditingStorage;
_cardLogic = cardLogic;
_accountLogic = accountLogic;
} }
public bool Create(CreditingBindingModel model) public bool Create(CreditingBindingModel model)

View File

@ -3,12 +3,12 @@ using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.BusinessLogicsContracts;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BankYouBankruptContracts.ViewModels.Client.Default;
namespace BankYouBankruptBusinessLogic.BusinessLogics namespace BankYouBankruptBusinessLogic.BusinessLogics
{ {

View File

@ -4,12 +4,12 @@ using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.BusinessLogicsContracts;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BankYouBankruptContracts.ViewModels.Client.Reports;
namespace BankYouBankruptBusinessLogic.BusinessLogics namespace BankYouBankruptBusinessLogic.BusinessLogics
{ {

View File

@ -1,4 +1,5 @@
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels;
using BankYouBankruptContracts.ViewModels.Client.Reports;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,5 @@
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels;
using BankYouBankruptContracts.ViewModels.Client.Default;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Text; using System.Text;

View File

@ -1,6 +1,7 @@
using BankYouBankruptCashierApp.Models; using BankYouBankruptCashierApp.Models;
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels;
using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDataModels.Enums; using BankYouBankruptDataModels.Enums;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Diagnostics; using System.Diagnostics;
@ -8,7 +9,7 @@ using System.Xml.Linq;
namespace BankYouBankruptCashierApp.Controllers namespace BankYouBankruptCashierApp.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;

View File

@ -1,4 +1,4 @@
@using BankYouBankruptContracts.ViewModels @using BankYouBankruptContracts.ViewModels.Client.Default
@model List<CreditingViewModel> @model List<CreditingViewModel>

View File

@ -1,4 +1,5 @@
@using BankYouBankruptContracts.ViewModels @using BankYouBankruptContracts.ViewModels.Client.Default
@model List<DebitingViewModel> @model List<DebitingViewModel>

View File

@ -1,4 +1,4 @@
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Text; using System.Text;

View File

@ -1,6 +1,9 @@
using BankYouBankruptClientApp.Models; using BankYouBankruptClientApp.Models;
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels;
using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptContracts.ViewModels.Client.Reports;
using BankYouBankruptContracts.ViewModels.Client.Diagram;
using BankYouBankruptDataModels.Enums; using BankYouBankruptDataModels.Enums;
using BankYouBankruptСlientApp; using BankYouBankruptСlientApp;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -24,7 +27,7 @@ namespace BankYouBankruptClientApp.Controllers
_logger = logger; _logger = logger;
} }
#region Профиль, вход и регистрация
[HttpGet] [HttpGet]
public IActionResult Profile() public IActionResult Profile()
{ {
@ -103,6 +106,7 @@ namespace BankYouBankruptClientApp.Controllers
return; return;
} }
#endregion
#region Карты #region Карты
[HttpGet] [HttpGet]
@ -244,7 +248,6 @@ namespace BankYouBankruptClientApp.Controllers
#endregion #endregion
#region Получение отчёта PDF #region Получение отчёта PDF
[HttpGet] [HttpGet]
@ -335,7 +338,8 @@ namespace BankYouBankruptClientApp.Controllers
#endregion #endregion
[HttpGet] #region Получение отчета по картам
[HttpGet]
public IActionResult ReportWithCards() public IActionResult ReportWithCards()
{ {
if (APIClient.Client == null) if (APIClient.Client == null)
@ -396,5 +400,36 @@ namespace BankYouBankruptClientApp.Controllers
Operations = result, Operations = result,
}); });
} }
#endregion
[HttpGet]
public IActionResult Diagram() {
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 Diagram(int cardId)
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}");
return View(new ClientDiagramViewModel() {
DiagramName = "Hello World",
Elements = APIClient.GetRequest<List<ClientDiagramElementsViewModel>>($"api/Card/getCardMonthResult?cardId={cardId}")
});
}
} }
} }

View File

@ -1,4 +1,4 @@
@using BankYouBankruptContracts.ViewModels @using BankYouBankruptContracts.ViewModels.Client.Default
@model List<CardViewModel> @model List<CardViewModel>

View File

@ -1,4 +1,4 @@
@using BankYouBankruptContracts.ViewModels @using BankYouBankruptContracts.ViewModels.Client.Default
@model List<CreditingViewModel> @model List<CreditingViewModel>

View File

@ -1,4 +1,4 @@
@using BankYouBankruptContracts.ViewModels @using BankYouBankruptContracts.ViewModels.Client.Default
@model List<DebitingViewModel> @model List<DebitingViewModel>

View File

@ -0,0 +1,78 @@
@using BankYouBankruptContracts.ViewModels.Client.Diagram
@model ClientDiagramViewModel
@{
ViewData["Title"] = "Диаграмма";
}
<div class="text-center">
<h1 class="display-4">Диаграмма по месяцам</h1>
</div>
<form method="post">
<div class="row">
<div class="row">Номер счета:</div>
<div class="col-8">
<select id="cardId" name="cardId" class="form-control" asp-items="@(new SelectList( @ViewBag.Cards, "Id", "Number"))"></select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Выбрать" class="btn btn-primary"/>
</div>
</div>
</form>
@if (Model == null) return;
<div id="Diagrams" class="text-center">
<div id="@Model.DiagramName Diagram">
<canvas id="Chart"></canvas>
<div id="params">
@foreach (var info in Model.Elements) {
<input type="hidden" id="@info.Name" value="@info.Value" />
}
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const diagrams = document.getElementById('Diagrams').childNodes;
let diagram_name = diagrams[1].id;
console.log(diagram_name);
let diagram = document.getElementById(diagram_name).childNodes;
console.log(diagram);
let labels = [];
let data = [];
document.getElementById('params').childNodes.forEach(element => {
if (element.id != undefined) {
labels.push(element.id);
}
});
document.getElementById('params').childNodes.forEach(element => {
if (element.id != undefined) {
data.push(Number(element.value));
}
});
new Chart(diagram.item(1), {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Денег в этом месяце',
data: data,
borderWidth: 1
}]
},
options: {
}
});
</script>

View File

@ -1,4 +1,4 @@
@using BankYouBankruptContracts.ViewModels @using BankYouBankruptContracts.ViewModels.Client.Default
@model ClientViewModel @model ClientViewModel

View File

@ -1,4 +1,4 @@
@using BankYouBankruptContracts.ViewModels @using BankYouBankruptContracts.ViewModels.Client.Reports;
@model ReportClientCardsViewModel @model ReportClientCardsViewModel

View File

@ -40,6 +40,9 @@
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreateReport">Отчёт за период</a> <a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreateReport">Отчёт за период</a>
</li> </li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Diagram">Диаграмма</a>
</li>
</ul> </ul>
} }
} }

View File

@ -1,6 +1,7 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptContracts.ViewModels.Client.Diagram;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -20,5 +21,7 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts
bool Update(CardBindingModel model); bool Update(CardBindingModel model);
bool Delete(CardBindingModel model); bool Delete(CardBindingModel model);
public List<ClientDiagramElementsViewModel> GetMonthInfo(int CardId);
} }
} }

View File

@ -1,6 +1,6 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -20,5 +20,6 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts
bool Update(ClientBindingModel model); bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model); bool Delete(ClientBindingModel model);
} }
} }

View File

@ -1,6 +1,6 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,6 +1,6 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,6 +1,6 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Reports;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,6 +1,6 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,6 +1,6 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,6 +1,6 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,6 +1,6 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -6,7 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels.Client.Default
{ {
public class CardViewModel : ICardModel public class CardViewModel : ICardModel
{ {

View File

@ -6,7 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels.Client.Default
{ {
public class ClientViewModel : IClientModel public class ClientViewModel : IClientModel
{ {

View File

@ -7,7 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels.Client.Default
{ {
public class CreditingViewModel : ICreditingModel public class CreditingViewModel : ICreditingModel
{ {

View File

@ -7,7 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels.Client.Default
{ {
public class DebitingViewModel : IDebitingModel public class DebitingViewModel : IDebitingModel
{ {
@ -22,12 +22,12 @@ namespace BankYouBankruptContracts.ViewModels
public int Sum { get; set; } public int Sum { get; set; }
[DisplayName("Дата открытия заявки")] [DisplayName("Дата открытия заявки")]
public DateTime DateOpen { get; set; } = DateTime.Now; public DateTime DateOpen { get; set; } = DateTime.Now;
[DisplayName("Дата закрытия заявки")] [DisplayName("Дата закрытия заявки")]
public DateTime? DateClose { get; set; } public DateTime? DateClose { get; set; }
[DisplayName("Статус заявки")] [DisplayName("Статус заявки")]
public StatusEnum Status { get; set; } public StatusEnum Status { get; set; }
} }
} }

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.Client.Diagram
{
public class ClientDiagramElementsViewModel
{
public string Name { get; set; } = "Column";
public int Value { get; set; } = 0;
}
}

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.Client.Diagram
{
public class ClientDiagramViewModel
{
public string DiagramName { get; set; } = "Diagram Name";
public List<ClientDiagramElementsViewModel> Elements { get; set; } = new();
}
}

View File

@ -6,7 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels.Client.Reports
{ {
public class CheckboxViewModel public class CheckboxViewModel
{ {

View File

@ -4,9 +4,9 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels.Client.Reports
{ {
internal class ReportCardViewModel internal class ReportCardViewModel
{ {
} }
} }

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels.Client.Reports
{ {
public class ReportClientCardsViewModel public class ReportClientCardsViewModel
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels.Client.Reports
{ {
public class ReportClientViewModel public class ReportClientViewModel
{ {

View File

@ -8,8 +8,8 @@ using System.Threading.Tasks;
namespace BankYouBankruptContracts.ViewModels namespace BankYouBankruptContracts.ViewModels
{ {
public class ClientSelectViewModel public class ClientSelectViewModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string FullName { get; set; } = string.Empty; public string FullName { get; set; } = string.Empty;

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankYouBankruptDataModels.Enums
{
public enum Months
{
Январь = 1,
Февраль, Март, Апрель, Май, Июнь,
Июль, Август, Сентябрь, Октябрь, Ноябрь, Декабрь
};
}

View File

@ -1,7 +1,7 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDatabaseImplement.Models; using BankYouBankruptDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace BankYouBankruptDatabaseImplement.Implements namespace BankYouBankruptDatabaseImplement.Implements
{ {
public class CardStorage : ICardStorage public class CardStorage : ICardStorage
{ {
public CardViewModel? Delete(CardBindingModel model) public CardViewModel? Delete(CardBindingModel model)
{ {

View File

@ -1,7 +1,7 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDatabaseImplement.Models; using BankYouBankruptDatabaseImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace BankYouBankruptDatabaseImplement.Implements namespace BankYouBankruptDatabaseImplement.Implements
{ {
public class ClientStorage : IClientStorage public class ClientStorage : IClientStorage
{ {
public ClientViewModel? Delete(ClientBindingModel model) public ClientViewModel? Delete(ClientBindingModel model)
{ {

View File

@ -1,7 +1,7 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDatabaseImplement.Models; using BankYouBankruptDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
@ -28,35 +28,22 @@ namespace BankYouBankruptDatabaseImplement.Implements
public List<CreditingViewModel> GetFilteredList(CreditingSearchModel model) public List<CreditingViewModel> GetFilteredList(CreditingSearchModel model)
{ {
using var context = new BankYouBancruptDatabase(); using var context = new BankYouBancruptDatabase();
var result = context.Creditings.Include(x => x.Card).ToList();
if (model.Status.HasValue) if (model.Status.HasValue) result = result.Where(x => x.Status == model.Status).ToList();
{
return context.Creditings
.Include(x => x.Card)
.Where(x => x.Status == model.Status)
.Select(x => x.GetViewModel)
.ToList();
}
if (model.UserId.HasValue) if (model.UserId.HasValue)
{ {
List<int> cards = context.Cards.Where(x => x.ClientID == model.UserId).Select(x => x.Id).ToList(); List<int> cards = context.Cards.Where(x => x.ClientID == model.UserId).Select(x => x.Id).ToList();
return context.Creditings.Include(x => x.Card).Where(x => cards.Contains(x.CardId)).Select(x => x.GetViewModel).ToList(); result = result.Where(x => cards.Contains(x.CardId)).ToList();
} }
if(model.DateFrom.HasValue && model.DateTo.HasValue) if (model.DateFrom.HasValue && model.DateTo.HasValue)
{ {
return context.Creditings result = result.Where(x => x.DateOpen >= model.DateFrom && x.DateClose <= model.DateTo).ToList();
.Include(x => x.Card)
.Where(x => x.DateOpen >= model.DateFrom && x.DateClose <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
} }
return context.Creditings return result.Select(x => x.GetViewModel).ToList();
.Include(x => x.Card)
.Select(x => x.GetViewModel)
.ToList();
} }
public CreditingViewModel? GetElement(CreditingSearchModel model) public CreditingViewModel? GetElement(CreditingSearchModel model)

View File

@ -1,7 +1,7 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.StoragesContracts; using BankYouBankruptContracts.StoragesContracts;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDatabaseImplement.Models; using BankYouBankruptDatabaseImplement.Models;
using BankYouBankruptDataModels.Enums; using BankYouBankruptDataModels.Enums;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -30,34 +30,23 @@ namespace BankYouBankruptDatabaseImplement.Implements
{ {
using var context = new BankYouBancruptDatabase(); using var context = new BankYouBancruptDatabase();
var result = context.Debitings.Include(x => x.Card).ToList();
//для получения всех заявок на стнятие со статусом "Открыта" //для получения всех заявок на стнятие со статусом "Открыта"
if(model.Status == StatusEnum.Открыта) if (model.Status.HasValue) result = result.Where(x => x.Status == model.Status).ToList();
{
return context.Debitings
.Include(x => x.Card)
.Where(x => x.Status == StatusEnum.Открыта)
.Select(x => x.GetViewModel)
.ToList();
}
if (model.UserId.HasValue) { if (model.UserId.HasValue) {
List<int> cards = context.Cards.Where(x => x.ClientID == model.UserId).Select(x => x.Id).ToList(); List<int> cards = context.Cards.Where(x => x.ClientID == model.UserId).Select(x => x.Id).ToList();
return context.Debitings.Include(x => x.Card).Where(x => cards.Contains(x.CardId)).Select(x => x.GetViewModel).ToList(); result = result.Where(x => cards.Contains(x.CardId)).ToList();
} }
if (model.DateFrom.HasValue && model.DateTo.HasValue) if (model.DateFrom.HasValue && model.DateTo.HasValue)
{ {
return context.Debitings result = result.Where(x => x.DateOpen <= model.DateFrom && x.DateClose >= model.DateTo && x.Status != StatusEnum.Отклонено).ToList();
.Include(x => x.Card) }
.Where(x => x.DateOpen <= model.DateFrom && x.DateClose >= model.DateTo && x.Status != StatusEnum.Отклонено)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Debitings return result.Select(x => x.GetViewModel).ToList();
.Include(x => x.Card)
.Select(x => x.GetViewModel)
.ToList();
} }
public DebitingViewModel? GetElement(DebitingSearchModel model) public DebitingViewModel? GetElement(DebitingSearchModel model)

View File

@ -1,5 +1,5 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDataModels.Models; using BankYouBankruptDataModels.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;

View File

@ -1,5 +1,4 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Models; using BankYouBankruptDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -8,6 +7,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BankYouBankruptContracts.ViewModels.Client.Default;
namespace BankYouBankruptDatabaseImplement.Models namespace BankYouBankruptDatabaseImplement.Models
{ {

View File

@ -1,5 +1,5 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDataModels.Enums; using BankYouBankruptDataModels.Enums;
using BankYouBankruptDataModels.Models; using BankYouBankruptDataModels.Models;
using System; using System;

View File

@ -1,5 +1,5 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDataModels.Enums; using BankYouBankruptDataModels.Enums;
using BankYouBankruptDataModels.Models; using BankYouBankruptDataModels.Models;
using System; using System;

View File

@ -3,14 +3,15 @@ using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.BusinessLogicsContracts;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels;
using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptDatabaseImplement.Models; using BankYouBankruptDatabaseImplement.Models;
using BankYouBankruptDataModels.Enums; using BankYouBankruptDataModels.Enums;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace BankYouBankruptRestApi.Controllers namespace BankYouBankruptRestApi.Controllers
{ {
//указание у контроллера, что Route будет строиться не только по наванию контроллера, но и по названию метода (так как у нас два Post-метода) //указание у контроллера, что Route будет строиться не только по наванию контроллера, но и по названию метода (так как у нас два Post-метода)
[Route("api/[controller]/[action]")] [Route("api/[controller]/[action]")]
[ApiController] [ApiController]
public class AccountController : Controller public class AccountController : Controller
{ {

View File

@ -1,7 +1,9 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptBusinessLogic.BusinessLogics;
using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.BusinessLogicsContracts;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptContracts.ViewModels.Client.Diagram;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Net; using System.Net;
@ -100,7 +102,7 @@ namespace BankYouBankruptRestApi.Controllers
} }
[HttpGet] [HttpGet]
public CardViewModel FindCard(int id) public CardViewModel? FindCard(int id)
{ {
try try
{ {
@ -115,5 +117,19 @@ namespace BankYouBankruptRestApi.Controllers
throw; throw;
} }
} }
}
[HttpGet]
public List<ClientDiagramElementsViewModel> getCardMonthResult(int cardId)
{
try
{
return _cardLogic.GetMonthInfo(cardId);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения пользователей");
throw;
}
}
}
} }

View File

@ -2,8 +2,10 @@
using BankYouBankruptContracts.BindingModels; using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.BusinessLogicsContracts;
using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.SearchModels;
using BankYouBankruptContracts.ViewModels; using BankYouBankruptContracts.ViewModels.Client.Default;
using BankYouBankruptContracts.ViewModels.Client.Diagram;
using DocumentFormat.OpenXml.Office2010.Excel; using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Spreadsheet;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace BankYouBankruptRestApi.Controllers namespace BankYouBankruptRestApi.Controllers
@ -137,5 +139,7 @@ namespace BankYouBankruptRestApi.Controllers
throw; throw;
} }
} }
} }
} }