Ну, типо работает (пока что)
This commit is contained in:
parent
1292f1a520
commit
0ade8d57ca
@ -25,17 +25,39 @@ namespace BankYouBankruptDatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<AccountViewModel> GetFilteredList(AccountSearchModel model)
|
public List<AccountViewModel> GetFilteredList(AccountSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.AccountNumber))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new BankYouBancruptDatabase();
|
using var context = new BankYouBancruptDatabase();
|
||||||
|
|
||||||
return context.Accounts
|
if (!string.IsNullOrEmpty(model.AccountNumber))
|
||||||
|
{
|
||||||
|
return context.Accounts
|
||||||
|
.Include(x => x.Client)
|
||||||
.Where(x => x.AccountNumber.Contains(model.AccountNumber))
|
.Where(x => x.AccountNumber.Contains(model.AccountNumber))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.CashierId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Accounts
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Where(x => x.CashierId == model.CashierId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Accounts
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return context.Accounts
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountViewModel? GetElement(AccountSearchModel model)
|
public AccountViewModel? GetElement(AccountSearchModel model)
|
||||||
|
@ -3,6 +3,7 @@ using BankYouBankruptContracts.SearchModels;
|
|||||||
using BankYouBankruptContracts.StoragesContracts;
|
using BankYouBankruptContracts.StoragesContracts;
|
||||||
using BankYouBankruptContracts.ViewModels;
|
using BankYouBankruptContracts.ViewModels;
|
||||||
using BankYouBankruptDatabaseImplement.Models;
|
using BankYouBankruptDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -43,16 +44,29 @@ namespace BankYouBankruptDatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<CardViewModel> GetFilteredList(CardSearchModel model)
|
public List<CardViewModel> GetFilteredList(CardSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.Number))
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new BankYouBancruptDatabase();
|
using var context = new BankYouBancruptDatabase();
|
||||||
|
|
||||||
return context.Cards
|
if (!string.IsNullOrEmpty(model.Number))
|
||||||
.Where(x => x.Number.Contains(model.Number))
|
{
|
||||||
.Select(x => x.GetViewModel)
|
return context.Cards
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Where(x => x.Number.Contains(model.Number))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.ClientID.HasValue)
|
||||||
|
{
|
||||||
|
return context.Cards
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Where(x => x.ClientID == model.ClientID)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return context.Cards
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ namespace BankYouBankruptDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
Client = context.Clients.First(x => x.Id == model.ClientId),
|
|
||||||
PasswordAccount = model.PasswordAccount,
|
PasswordAccount = model.PasswordAccount,
|
||||||
Balance = model.Balance,
|
Balance = model.Balance,
|
||||||
DateOpen = model.DateOpen,
|
DateOpen = model.DateOpen,
|
||||||
@ -78,6 +77,8 @@ namespace BankYouBankruptDatabaseImplement.Models
|
|||||||
Id = Id,
|
Id = Id,
|
||||||
CashierId = CashierId,
|
CashierId = CashierId,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
|
Name = Client.Name,
|
||||||
|
Patronymic = Client.Patronymic,
|
||||||
AccountNumber = AccountNumber,
|
AccountNumber = AccountNumber,
|
||||||
Balance = Balance,
|
Balance = Balance,
|
||||||
PasswordAccount = PasswordAccount,
|
PasswordAccount = PasswordAccount,
|
||||||
|
@ -18,7 +18,7 @@ namespace BankYouBankruptDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int ClientID { get; set; }
|
public int ClientID { get; set; }
|
||||||
|
|
||||||
public virtual Client Client { get; set; } = new();
|
public virtual Client Client { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int AccountId { get; set; }
|
public int AccountId { get; set; }
|
||||||
@ -56,7 +56,6 @@ namespace BankYouBankruptDatabaseImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
AccountId = model.AccountId,
|
AccountId = model.AccountId,
|
||||||
ClientID = model.ClientID,
|
ClientID = model.ClientID,
|
||||||
Client = context.Clients.First(x => x.Id == model.ClientID),
|
|
||||||
Number = model.Number,
|
Number = model.Number,
|
||||||
Period = model.Period,
|
Period = model.Period,
|
||||||
CVC = model.CVC
|
CVC = model.CVC
|
||||||
|
Loading…
Reference in New Issue
Block a user