Осталось обновление заявок и отчеты
This commit is contained in:
parent
a655f961e7
commit
57c5508b9a
@ -3,6 +3,7 @@ using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.StoragesContracts;
|
||||
using BankContracts.ViewModels;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -34,6 +35,18 @@ namespace BankBusinessLogic.BusinessLogic
|
||||
_logger.LogInformation("ReadList Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public List<CardViewModel>? ReadListByRequestId(CardSearchModel model)
|
||||
{
|
||||
_logger.LogInformation("ReadListByRequestId. Number: {Number}, Id: {Id}", model?.Number, model?.Id);
|
||||
var list = _cardStorage.GetListForRequest(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadListByRequestId return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadListByRequestId Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public CardViewModel? ReadElement(CardSearchModel model)
|
||||
{
|
||||
_logger.LogInformation("ReadElement Number: {Number}, Id: {Id}", model?.Number, model?.Id);
|
||||
|
@ -47,6 +47,19 @@ namespace BankBusinessLogic.BusinessLogic
|
||||
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool LinkOperationTransfer(int operationId, int transferId)
|
||||
{
|
||||
if (operationId <= 0 || transferId <= 0)
|
||||
return false;
|
||||
if (_operationStorage.LinkOperationTransfer(operationId, transferId))
|
||||
{
|
||||
_logger.LogWarning("link operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Create(OperationBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
@ -23,10 +23,10 @@ namespace BankBusinessLogic.BusinessLogic
|
||||
_requestStorage = requestStorage;
|
||||
}
|
||||
|
||||
public List<RequestViewModel>? ReadList(RequestSearchModel? model)
|
||||
public List<RequestViewModel>? ReadList(RequestSearchModel? model, int? clientId)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _requestStorage.GetFullList() : _requestStorage.GetFilteredList(model);
|
||||
var list = model == null ? _requestStorage.GetFullList(clientId) : _requestStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
@ -1,7 +1,9 @@
|
||||
using BankClientApp.Models;
|
||||
using BankContracts.BindingModels;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDatabaseImplement.Models;
|
||||
using BankDataModels.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using System.Diagnostics;
|
||||
@ -183,6 +185,21 @@ namespace BankClientApp.Controllers
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CardViewModel>? GetCards(int requestId)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
var result = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcards?requestid={requestId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CardDelete()
|
||||
{
|
||||
@ -335,13 +352,24 @@ namespace BankClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Operations = APIClient.GetRequest<List<OperationViewModel>>($"api/operation/getoperationlist?clientid={APIClient.Client.Id}");
|
||||
ViewBag.Transfers = APIClient.GetRequest<List<TransferViewModel>>($"api/transfer/gettransferlist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void OperationTransfer(int operation, int transfer)
|
||||
{
|
||||
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/operation/linkoperationtransfer", new OperationBindingModel
|
||||
{
|
||||
Id = operation,
|
||||
TransferId = transfer,
|
||||
});
|
||||
Response.Redirect("Operation");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -353,7 +381,7 @@ namespace BankClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(new List<RequestViewModel>());
|
||||
return View(APIClient.GetRequest<List<RequestViewModel>>($"api/request/getrequestlist?clientid={APIClient.Client.Id}"));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -363,10 +391,29 @@ namespace BankClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Cards = new List<CardViewModel>();
|
||||
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcardlist?clientid={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void RequestCreate(int sum, List<int> cards)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
Dictionary<int, ICardModel> a = new Dictionary<int, ICardModel>();
|
||||
foreach(int card in cards)
|
||||
{
|
||||
a.Add(card, new CardSearchModel() { Id = card } as ICardModel);
|
||||
}
|
||||
APIClient.PostRequest("/api/request/createrequest", new RequestBindingModel
|
||||
{
|
||||
Sum = sum,
|
||||
CardRequests = a,
|
||||
Status = RequestStatus.Неизвестен
|
||||
});
|
||||
Response.Redirect("Request");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult RequestUpdate()
|
||||
{
|
||||
@ -374,11 +421,30 @@ namespace BankClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Requests = new List<RequestViewModel>();
|
||||
ViewBag.Cards = new List<CardViewModel>();
|
||||
ViewBag.Requests = APIClient.GetRequest<List<RequestViewModel>>($"api/request/getrequestlist?clientid={APIClient.Client.Id}");
|
||||
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcardlist?clientid={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void RequestUpdate(int sum, List<int> cards)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
Dictionary<int, ICardModel> a = new Dictionary<int, ICardModel>();
|
||||
foreach (int card in cards)
|
||||
{
|
||||
a.Add(card, new CardSearchModel() { Id = card } as ICardModel);
|
||||
}
|
||||
APIClient.PostRequest("/api/request/updaterequest", new RequestBindingModel
|
||||
{
|
||||
Sum = sum,
|
||||
CardRequests = a,
|
||||
Status = RequestStatus.Неизвестен
|
||||
});
|
||||
Response.Redirect("Request");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult RequestDelete()
|
||||
{
|
||||
@ -386,13 +452,29 @@ namespace BankClientApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Requests = new List<RequestViewModel>();
|
||||
ViewBag.Requests = APIClient.GetRequest<List<RequestViewModel>>($"api/request/getrequestlist?clientid={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
#endregion
|
||||
|
||||
[HttpPost]
|
||||
public void RequestDelete(int request)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/request/deleterequest", new
|
||||
RequestBindingModel
|
||||
{
|
||||
Id = request,
|
||||
});
|
||||
Response.Redirect("Request");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region//работа с отчетами
|
||||
[HttpGet]
|
||||
[HttpGet]
|
||||
public IActionResult Report()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
|
@ -17,6 +17,7 @@
|
||||
<a asp-action="OperationCreate">Создать операцию</a>
|
||||
<a asp-action="OperationUpdate">Обновить операцию</a>
|
||||
<a asp-action="OperationDelete">Удалить операцию</a>
|
||||
<a asp-action="OperationTransfer">Привязать перевод</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -1,6 +1,4 @@
|
||||
//todo выводить список только для выбранного клиента
|
||||
|
||||
@{
|
||||
@{
|
||||
ViewData["Title"] = "OperationTransfer";
|
||||
}
|
||||
<div class="text-center">
|
||||
@ -78,7 +76,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-8"><input type="submit" value="Связать" class="btn btn-danger" /></div>
|
||||
<div class="col-8"><input type="submit" value="Связать" class="btn btn-success" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@ -93,10 +91,10 @@
|
||||
url: "/Home/GetTransfer",
|
||||
data: { transferId: transfer },
|
||||
success: function (result) {
|
||||
$('#sum').val(result.item1.Sum);
|
||||
$('#transfersender-number').val(result.item1.senderAccountNumber);
|
||||
$('#transferrecipient-number').val(result.item1.recipientAccountNumber);
|
||||
$('#transferdate').val(result.item1.transferTime);
|
||||
$('#sum').val(result.Sum);
|
||||
$('#transfersender-number').val(result.senderAccountNumber);
|
||||
$('#transferrecipient-number').val(result.recipientAccountNumber);
|
||||
$('#transferdate').val(result.transferTime);
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -109,10 +107,10 @@
|
||||
url: "/Home/GetOperation",
|
||||
data: { operationId: operation },
|
||||
success: function (result) {
|
||||
$('#sum').val(result.item1.Sum);
|
||||
$('#operationsender-number').val(result.item1.senderCardNumber);
|
||||
$('#operationrecipient-number').val(result.item1.recipientCardNumber);
|
||||
$('#operationdate').val(result.item1.transferTime);
|
||||
$('#sum').val(result.Sum);
|
||||
$('#operationsender-number').val(result.senderCardNumber);
|
||||
$('#operationrecipient-number').val(result.recipientCardNumber);
|
||||
$('#operationdate').val(result.operationTime);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -41,22 +41,22 @@
|
||||
<script>
|
||||
function check() {
|
||||
var cards = $('#cards').val();
|
||||
var request = $('#request').val();
|
||||
$("#cards option:selected").removeAttr("selected");
|
||||
if (cards) {
|
||||
if (cards && request) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetCards",
|
||||
data: { serviceId: service },
|
||||
data: { requestId: request },
|
||||
success: function (result) {
|
||||
console.log(result.item2);
|
||||
$('#name').val(result.item1.serviceName);
|
||||
$('#price').val(result.item1.price);
|
||||
$.map(result.item2, function (n) {
|
||||
console.log("#" + n);
|
||||
$.map(result, function (n) {
|
||||
$(`option[data-name=${n}]`).attr("selected", "selected")
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
$.ajax({
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -14,5 +14,6 @@ namespace BankContracts.BindingModels
|
||||
public DateTime OperationTime { get; set; }
|
||||
public int? SenderCardId { get; set; }
|
||||
public int RecipientCardId { get; set; }
|
||||
public int? TransferId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
List<OperationViewModel>? ReadList(OperationSearchModel? model, int? clientId);
|
||||
OperationViewModel? ReadElement(OperationSearchModel model);
|
||||
bool LinkOperationTransfer(int operationId, int transferId);
|
||||
bool Create(OperationBindingModel model);
|
||||
bool Update(OperationBindingModel model);
|
||||
bool Delete(OperationBindingModel model);
|
||||
|
@ -11,7 +11,7 @@ namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IRequestLogic
|
||||
{
|
||||
List<RequestViewModel>? ReadList(RequestSearchModel? model);
|
||||
List<RequestViewModel>? ReadList(RequestSearchModel? model, int? clientId);
|
||||
RequestViewModel? ReadElement(RequestSearchModel model);
|
||||
bool Create(RequestBindingModel model);
|
||||
bool Update(RequestBindingModel model);
|
||||
|
@ -14,5 +14,6 @@ namespace BankContracts.SearchModels
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public List<int>? SelectedCardIds { get; set; }
|
||||
public int? RequestId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace BankContracts.StoragesContracts
|
||||
{
|
||||
List<CardViewModel> GetFullList();
|
||||
List<CardViewModel> GetFilteredList(CardSearchModel model);
|
||||
List<CardViewModel> GetListForRequest(CardSearchModel model);
|
||||
List<ReportTransfersViewModel> GetReportTransfersList(CardSearchModel model);
|
||||
List<ReportOperationsRequestsViewModel> GetReportOperationsRequestsList(CardSearchModel model);
|
||||
CardViewModel? GetElement(CardSearchModel model);
|
||||
|
@ -17,5 +17,7 @@ namespace BankContracts.StoragesContracts
|
||||
OperationViewModel? Insert(OperationBindingModel model);
|
||||
OperationViewModel? Update(OperationBindingModel model);
|
||||
OperationViewModel? Delete(OperationBindingModel model);
|
||||
bool LinkOperationTransfer(int oprationId, int transferId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IRequestStorage
|
||||
{
|
||||
List<RequestViewModel> GetFullList();
|
||||
List<RequestViewModel> GetFullList(int? clientId);
|
||||
List<RequestViewModel> GetFilteredList(RequestSearchModel model);
|
||||
RequestViewModel? GetElement(RequestSearchModel model);
|
||||
RequestViewModel? Insert(RequestBindingModel model);
|
||||
|
@ -30,6 +30,15 @@ namespace BankDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CardViewModel> GetListForRequest(CardSearchModel model)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
return context.CardRequests
|
||||
.Include(x => x.Card).Include(x => x.Request)
|
||||
.Where(x => x.RequestId==model.RequestId)
|
||||
.Select(x => x.Card.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ReportTransfersViewModel> GetReportTransfersList(CardSearchModel model)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
|
@ -18,7 +18,7 @@ namespace BankDatabaseImplement.Implements
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
if (clientId != null) {
|
||||
return context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard)
|
||||
return context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).Include(x => x.Transfer)
|
||||
//todo узнать у ростислава по поводу фильтрации
|
||||
.Where(x => (x.SenderCard != null && x.SenderCard.ClientId == clientId) || (x.RecipientCard != null && x.RecipientCard.ClientId == clientId))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
@ -29,7 +29,7 @@ namespace BankDatabaseImplement.Implements
|
||||
public List<OperationViewModel> GetFilteredList(OperationSearchModel model)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
return context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard)
|
||||
return context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).Include(x => x.Transfer)
|
||||
.Where(x => (
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.OperationTime >= model.DateFrom ) &&
|
||||
@ -40,7 +40,7 @@ namespace BankDatabaseImplement.Implements
|
||||
{
|
||||
if (!model.Id.HasValue) return null;
|
||||
using var context = new BankDatabase();
|
||||
return context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard)
|
||||
return context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).Include(x => x.Transfer)
|
||||
.FirstOrDefault(x => ((model.Id.HasValue && x.Id == model.Id)
|
||||
))?.GetViewModel;
|
||||
}
|
||||
@ -59,7 +59,7 @@ namespace BankDatabaseImplement.Implements
|
||||
public OperationViewModel? Update(OperationBindingModel model)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
var operation = context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).FirstOrDefault(x => x.Id == model.Id);
|
||||
var operation = context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).Include(x => x.Transfer).FirstOrDefault(x => x.Id == model.Id);
|
||||
if (operation == null)
|
||||
{
|
||||
return null;
|
||||
@ -71,7 +71,7 @@ namespace BankDatabaseImplement.Implements
|
||||
public OperationViewModel? Delete(OperationBindingModel model)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
var operation = context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
var operation = context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).Include(x => x.Transfer).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (operation != null)
|
||||
{
|
||||
context.Operations.Remove(operation);
|
||||
@ -80,5 +80,26 @@ namespace BankDatabaseImplement.Implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool LinkOperationTransfer(int operationId, int transferId)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
var transfer = context.Transfers.Include(x => x.SenderAccount).Include(x => x.RecipientAccount).Include(x => x.Operation).FirstOrDefault(rec => rec.Id == transferId);
|
||||
if (transfer == null || operationId <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var newTransfer = new TransferBindingModel
|
||||
{
|
||||
Sum = transfer.Sum,
|
||||
TransferTime = transfer.TransferTime,
|
||||
OperationId = operationId,
|
||||
SenderAccountId = transfer.SenderAccountId,
|
||||
RecipientAccountId = transfer.RecipientAccountId,
|
||||
};
|
||||
transfer.Update(newTransfer);
|
||||
context.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,14 +15,23 @@ namespace BankDatabaseImplement.Implements
|
||||
{
|
||||
public class RequestStorage : IRequestStorage
|
||||
{
|
||||
public List<RequestViewModel> GetFullList()
|
||||
public List<RequestViewModel> GetFullList(int? clientId)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
return context.Requests
|
||||
.Include(x => x.Cards)
|
||||
.ThenInclude(x => x.Card)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
if (clientId == null)
|
||||
{
|
||||
return context.Requests
|
||||
.Include(x => x.Cards)
|
||||
.ThenInclude(x => x.Card)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.CardRequests
|
||||
.Include(x => x.Card)
|
||||
.Include(x => x.Request)
|
||||
.Where(x => x.Card.ClientId == clientId)
|
||||
.Select(x => x.Request.GetViewModel).Distinct()
|
||||
.ToList();
|
||||
}
|
||||
public List<RequestViewModel> GetFilteredList(RequestSearchModel model)
|
||||
|
@ -47,7 +47,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ManagerId");
|
||||
|
||||
b.ToTable("Accounts");
|
||||
b.ToTable("Accounts", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.AccountWithdrawal", b =>
|
||||
@ -73,7 +73,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("WithdrawalId");
|
||||
|
||||
b.ToTable("AccountWithdrawals");
|
||||
b.ToTable("AccountWithdrawals", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.Card", b =>
|
||||
@ -109,7 +109,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Cards");
|
||||
b.ToTable("Cards", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.CardRequest", b =>
|
||||
@ -132,7 +132,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("RequestId");
|
||||
|
||||
b.ToTable("CardRequests");
|
||||
b.ToTable("CardRequests", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.Client", b =>
|
||||
@ -157,7 +157,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
b.ToTable("Clients", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.Manager", b =>
|
||||
@ -182,7 +182,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Managers");
|
||||
b.ToTable("Managers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.Operation", b =>
|
||||
@ -212,7 +212,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("SenderCardId");
|
||||
|
||||
b.ToTable("Operations");
|
||||
b.ToTable("Operations", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.Request", b =>
|
||||
@ -234,7 +234,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Requests");
|
||||
b.ToTable("Requests", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.Transfer", b =>
|
||||
@ -270,7 +270,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("SenderAccountId");
|
||||
|
||||
b.ToTable("Transfers");
|
||||
b.ToTable("Transfers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.Withdrawal", b =>
|
||||
@ -293,7 +293,7 @@ namespace BankDatabaseImplement.Migrations
|
||||
.IsUnique()
|
||||
.HasFilter("[RequestId] IS NOT NULL");
|
||||
|
||||
b.ToTable("Withdrawals");
|
||||
b.ToTable("Withdrawals", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BankDatabaseImplement.Models.Account", b =>
|
||||
|
@ -25,7 +25,7 @@ namespace BankDatabaseImplement.Models
|
||||
[Required]
|
||||
public int RecipientCardId { get; set; }
|
||||
public virtual Card? RecipientCard { get; private set; }
|
||||
public virtual Transfer? Transfer { get; private set; }
|
||||
public virtual Transfer? Transfer { get; private set; } = null;
|
||||
|
||||
public static Operation? Create(OperationBindingModel model)
|
||||
{
|
||||
@ -46,7 +46,7 @@ namespace BankDatabaseImplement.Models
|
||||
Sum = model.Sum;
|
||||
SenderCardId = model.SenderCardId;
|
||||
RecipientCardId = model.RecipientCardId;
|
||||
}
|
||||
}
|
||||
|
||||
public OperationViewModel GetViewModel => new()
|
||||
{
|
||||
@ -57,6 +57,7 @@ namespace BankDatabaseImplement.Models
|
||||
RecipientCardId = RecipientCardId,
|
||||
SenderCardNumber = SenderCard?.Number ?? string.Empty,
|
||||
RecipientCardNumber = RecipientCard?.Number ?? string.Empty,
|
||||
TransferId = Transfer?.Id,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace BankDatabaseImplement.Models
|
||||
{
|
||||
if (_cardRequests == null)
|
||||
{
|
||||
_cardRequests = Cards.ToDictionary(recPC => recPC.CardId, recPC => recPC.Card as ICardModel);
|
||||
_cardRequests = Cards.ToDictionary(card => card.CardId, card => card.Card as ICardModel);
|
||||
}
|
||||
return _cardRequests;
|
||||
}
|
||||
@ -74,6 +74,11 @@ namespace BankDatabaseImplement.Models
|
||||
{ // удалили те, которых нет в модели
|
||||
context.CardRequests.RemoveRange(CardRequests.Where(rec => !model.CardRequests.ContainsKey(rec.CardId)));
|
||||
context.SaveChanges();
|
||||
foreach (var updateCards in CardRequests)
|
||||
{
|
||||
model.CardRequests.Remove(updateCards.CardId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var Request = context.Requests.First(x => x.Id == Id);
|
||||
foreach (var request in model.CardRequests)
|
||||
|
@ -2,6 +2,7 @@
|
||||
using BankContracts.BusinessLogicsContracts;
|
||||
using BankContracts.SearchModels;
|
||||
using BankContracts.ViewModels;
|
||||
using BankDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankRestApi.Controllers
|
||||
@ -35,6 +36,23 @@ namespace BankRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public List<CardViewModel>? GetCards(int requestId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(new CardSearchModel
|
||||
{
|
||||
RequestId = requestId,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка менеджеров");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public CardViewModel? GetCard(int cardId)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace BankRestApi.Controllers
|
||||
_logic = Operation;
|
||||
}
|
||||
[HttpGet]
|
||||
public List<OperationViewModel>? GetOperationList(int clientId)
|
||||
public List<OperationViewModel>? GetOperationList(int? clientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -90,5 +90,19 @@ namespace BankRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void LinkOperationTransfer(OperationBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.LinkOperationTransfer(model.Id, (int)model.TransferId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при связывании операции с переводом");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ namespace BankRestApi.Controllers
|
||||
_logic = Request;
|
||||
}
|
||||
[HttpGet]
|
||||
public List<RequestViewModel>? GetRequestList()
|
||||
public List<RequestViewModel>? GetRequestList(int clientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
return _logic.ReadList(null, clientId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user