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