Diagrams
This commit is contained in:
parent
4c40714bf0
commit
1ebcef575a
@ -3,12 +3,15 @@ using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Diagram;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
using DocumentFormat.OpenXml.Drawing;
|
||||
|
||||
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -17,11 +20,16 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICardStorage _cardStorage;
|
||||
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;
|
||||
_cardStorage = cardStorage;
|
||||
_accountStorage = accountStorage;
|
||||
_debitingLogic = debitingLogic;
|
||||
_creditingLogic = creditingLogic;
|
||||
}
|
||||
|
||||
public bool Create(CardBindingModel model)
|
||||
@ -88,6 +96,31 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
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)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -3,12 +3,12 @@ using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
|
||||
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
|
@ -3,12 +3,12 @@ using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
|
||||
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -16,14 +16,10 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
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;
|
||||
_creditingStorage = creditingStorage;
|
||||
_cardLogic = cardLogic;
|
||||
_accountLogic = accountLogic;
|
||||
}
|
||||
|
||||
public bool Create(CreditingBindingModel model)
|
||||
|
@ -3,12 +3,12 @@ using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
|
||||
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
|
@ -4,12 +4,12 @@ using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Reports;
|
||||
|
||||
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Reports;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using BankYouBankruptCashierApp.Models;
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
@ -8,7 +9,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace BankYouBankruptCashierApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
@using BankYouBankruptContracts.ViewModels
|
||||
@using BankYouBankruptContracts.ViewModels.Client.Default
|
||||
|
||||
@model List<CreditingViewModel>
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
@using BankYouBankruptContracts.ViewModels
|
||||
@using BankYouBankruptContracts.ViewModels.Client.Default
|
||||
|
||||
|
||||
@model List<DebitingViewModel>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
@ -1,7 +1,9 @@
|
||||
|
||||
using BankYouBankruptClientApp.Models;
|
||||
using BankYouBankruptClientApp.Models;
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Reports;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Diagram;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
using BankYouBankruptСlientApp;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -19,7 +21,7 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
#region Профиль, вход и регистрация
|
||||
[HttpGet]
|
||||
public IActionResult Profile()
|
||||
{
|
||||
@ -98,6 +100,7 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Карты
|
||||
[HttpGet]
|
||||
@ -238,7 +241,6 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Получение отчёта PDF
|
||||
|
||||
[HttpGet]
|
||||
@ -271,6 +273,7 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
|
||||
#endregion
|
||||
|
||||
#region Получение отчета по картам
|
||||
[HttpGet]
|
||||
public IActionResult ReportWithCards()
|
||||
{
|
||||
@ -332,5 +335,36 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
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}")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
@using BankYouBankruptContracts.ViewModels
|
||||
@using BankYouBankruptContracts.ViewModels.Client.Default
|
||||
|
||||
@model List<CardViewModel>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
@using BankYouBankruptContracts.ViewModels
|
||||
@using BankYouBankruptContracts.ViewModels.Client.Default
|
||||
|
||||
@model List<CreditingViewModel>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
@using BankYouBankruptContracts.ViewModels
|
||||
@using BankYouBankruptContracts.ViewModels.Client.Default
|
||||
|
||||
@model List<DebitingViewModel>
|
||||
|
||||
|
@ -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>
|
@ -1,4 +1,4 @@
|
||||
@using BankYouBankruptContracts.ViewModels
|
||||
@using BankYouBankruptContracts.ViewModels.Client.Default
|
||||
|
||||
@model ClientViewModel
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
@using BankYouBankruptContracts.ViewModels
|
||||
@using BankYouBankruptContracts.ViewModels.Client.Reports;
|
||||
|
||||
@model ReportClientCardsViewModel
|
||||
|
||||
|
@ -40,6 +40,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreateReport">Отчёт за период</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Diagram">Диаграмма</a>
|
||||
</li>
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Diagram;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -20,5 +21,7 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts
|
||||
bool Update(CardBindingModel model);
|
||||
|
||||
bool Delete(CardBindingModel model);
|
||||
|
||||
public List<ClientDiagramElementsViewModel> GetMonthInfo(int CardId);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -20,5 +20,6 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts
|
||||
bool Update(ClientBindingModel model);
|
||||
|
||||
bool Delete(ClientBindingModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Reports;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -6,9 +6,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptContracts.ViewModels
|
||||
namespace BankYouBankruptContracts.ViewModels.Client.Default
|
||||
{
|
||||
public class CardViewModel : ICardModel
|
||||
public class CardViewModel : ICardModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptContracts.ViewModels
|
||||
namespace BankYouBankruptContracts.ViewModels.Client.Default
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
@ -7,9 +7,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptContracts.ViewModels
|
||||
namespace BankYouBankruptContracts.ViewModels.Client.Default
|
||||
{
|
||||
public class CreditingViewModel : ICreditingModel
|
||||
public class CreditingViewModel : ICreditingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
@ -7,9 +7,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptContracts.ViewModels
|
||||
namespace BankYouBankruptContracts.ViewModels.Client.Default
|
||||
{
|
||||
public class DebitingViewModel : IDebitingModel
|
||||
public class DebitingViewModel : IDebitingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@ -22,12 +22,12 @@ namespace BankYouBankruptContracts.ViewModels
|
||||
public int Sum { get; set; }
|
||||
|
||||
[DisplayName("Дата открытия заявки")]
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
|
||||
[DisplayName("Дата закрытия заявки")]
|
||||
public DateTime? DateClose { get; set; }
|
||||
[DisplayName("Дата закрытия заявки")]
|
||||
public DateTime? DateClose { get; set; }
|
||||
|
||||
[DisplayName("Статус заявки")]
|
||||
public StatusEnum Status { get; set; }
|
||||
}
|
||||
[DisplayName("Статус заявки")]
|
||||
public StatusEnum Status { get; set; }
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptContracts.ViewModels
|
||||
namespace BankYouBankruptContracts.ViewModels.Client.Reports
|
||||
{
|
||||
public class CheckboxViewModel
|
||||
{
|
@ -4,9 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptContracts.ViewModels
|
||||
namespace BankYouBankruptContracts.ViewModels.Client.Reports
|
||||
{
|
||||
internal class ReportCardViewModel
|
||||
{
|
||||
}
|
||||
internal class ReportCardViewModel
|
||||
{
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptContracts.ViewModels
|
||||
namespace BankYouBankruptContracts.ViewModels.Client.Reports
|
||||
{
|
||||
public class ReportClientCardsViewModel
|
||||
{
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptContracts.ViewModels
|
||||
namespace BankYouBankruptContracts.ViewModels.Client.Reports
|
||||
{
|
||||
public class ReportClientViewModel
|
||||
{
|
@ -8,8 +8,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptContracts.ViewModels
|
||||
{
|
||||
public class ClientSelectViewModel
|
||||
{
|
||||
public class ClientSelectViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string FullName { get; set; } = string.Empty;
|
||||
|
15
BankYouBankrupt/BankYouBankruptDataModels/Enums/Months.cs
Normal file
15
BankYouBankrupt/BankYouBankruptDataModels/Enums/Months.cs
Normal 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,
|
||||
Февраль, Март, Апрель, Май, Июнь,
|
||||
Июль, Август, Сентябрь, Октябрь, Ноябрь, Декабрь
|
||||
};
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
@ -12,7 +12,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptDatabaseImplement.Implements
|
||||
{
|
||||
public class CardStorage : ICardStorage
|
||||
public class CardStorage : ICardStorage
|
||||
{
|
||||
public CardViewModel? Delete(CardBindingModel model)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -11,7 +11,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptDatabaseImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
@ -28,35 +28,22 @@ namespace BankYouBankruptDatabaseImplement.Implements
|
||||
public List<CreditingViewModel> GetFilteredList(CreditingSearchModel model)
|
||||
{
|
||||
using var context = new BankYouBancruptDatabase();
|
||||
var result = context.Creditings.Include(x => x.Card).ToList();
|
||||
|
||||
if (model.Status.HasValue)
|
||||
{
|
||||
return context.Creditings
|
||||
.Include(x => x.Card)
|
||||
.Where(x => x.Status == model.Status)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.Status.HasValue) result = result.Where(x => x.Status == model.Status).ToList();
|
||||
|
||||
if (model.UserId.HasValue)
|
||||
{
|
||||
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
|
||||
.Include(x => x.Card)
|
||||
.Where(x => x.DateOpen >= model.DateFrom && x.DateClose <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
result = result.Where(x => x.DateOpen >= model.DateFrom && x.DateClose <= model.DateTo).ToList();
|
||||
}
|
||||
|
||||
return context.Creditings
|
||||
.Include(x => x.Card)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
return result.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public CreditingViewModel? GetElement(CreditingSearchModel model)
|
||||
|
@ -1,7 +1,7 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.StoragesContracts;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDatabaseImplement.Models;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -30,34 +30,23 @@ namespace BankYouBankruptDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new BankYouBancruptDatabase();
|
||||
|
||||
var result = context.Debitings.Include(x => x.Card).ToList();
|
||||
|
||||
|
||||
//для получения всех заявок на стнятие со статусом "Открыта"
|
||||
if(model.Status == StatusEnum.Открыта)
|
||||
{
|
||||
return context.Debitings
|
||||
.Include(x => x.Card)
|
||||
.Where(x => x.Status == StatusEnum.Открыта)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.Status.HasValue) result = result.Where(x => x.Status == model.Status).ToList();
|
||||
|
||||
if (model.UserId.HasValue) {
|
||||
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)
|
||||
{
|
||||
return context.Debitings
|
||||
.Include(x => x.Card)
|
||||
.Where(x => x.DateOpen <= model.DateFrom && x.DateClose >= model.DateTo && x.Status != StatusEnum.Отклонено)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
result = result.Where(x => x.DateOpen <= model.DateFrom && x.DateClose >= model.DateTo && x.Status != StatusEnum.Отклонено).ToList();
|
||||
}
|
||||
|
||||
return context.Debitings
|
||||
.Include(x => x.Card)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
return result.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public DebitingViewModel? GetElement(DebitingSearchModel model)
|
||||
|
@ -1,5 +1,5 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDataModels.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -8,6 +7,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
|
||||
namespace BankYouBankruptDatabaseImplement.Models
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
using BankYouBankruptDataModels.Models;
|
||||
using System;
|
||||
|
@ -1,5 +1,5 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
using BankYouBankruptDataModels.Models;
|
||||
using System;
|
||||
|
@ -3,14 +3,15 @@ using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptDatabaseImplement.Models;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankYouBankruptRestApi.Controllers
|
||||
{
|
||||
//указание у контроллера, что Route будет строиться не только по наванию контроллера, но и по названию метода (так как у нас два Post-метода)
|
||||
[Route("api/[controller]/[action]")]
|
||||
//указание у контроллера, что Route будет строиться не только по наванию контроллера, но и по названию метода (так как у нас два Post-метода)
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class AccountController : Controller
|
||||
{
|
||||
|
@ -1,7 +1,9 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptBusinessLogic.BusinessLogics;
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Diagram;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net;
|
||||
@ -100,7 +102,7 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public CardViewModel FindCard(int id)
|
||||
public CardViewModel? FindCard(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -115,5 +117,19 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ClientDiagramElementsViewModel> getCardMonthResult(int cardId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _cardLogic.GetMonthInfo(cardId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения пользователей");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,10 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Default;
|
||||
using BankYouBankruptContracts.ViewModels.Client.Diagram;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankYouBankruptRestApi.Controllers
|
||||
@ -137,5 +139,7 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user