Снова правки

This commit is contained in:
Programmist73 2023-05-14 18:27:41 +04:00
parent 5fd23d0bc0
commit de25c5ce83
5 changed files with 17 additions and 11 deletions

View File

@ -21,6 +21,7 @@ namespace BankYouBankruptDatabaseImplement.Implements
using var context = new BankYouBancruptDatabase();
return context.Debitings
.Include(x => x.Card)
.Select(x => x.GetViewModel)
.ToList();
}
@ -38,12 +39,14 @@ namespace BankYouBankruptDatabaseImplement.Implements
if(model.Status != StatusEnum.Закрыта)
{
return context.Debitings
.Include(x => x.Card)
.Where(x => x.Status == StatusEnum.Открыта)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Debitings
.Include(x => x.Card)
.Where(x => x.CardId == model.CardId)
.Select(x => x.GetViewModel)
.ToList();
@ -59,6 +62,7 @@ namespace BankYouBankruptDatabaseImplement.Implements
using var context = new BankYouBancruptDatabase();
return context.Debitings
.Include(x => x.Card)
.FirstOrDefault(x => (!(model.CardId < 0) && x.CardId == model.CardId) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;

View File

@ -26,7 +26,7 @@ namespace BankYouBankruptDatabaseImplement.Models
public int ClientId { get; set; }
//для передачи ФИО клиента
public virtual Client Client { get; set; } = new();
public virtual Client Client { get; set; }
[Required]
public string PasswordAccount { get; set; } = string.Empty;
@ -58,6 +58,7 @@ 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,

View File

@ -1,6 +1,7 @@
using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -18,16 +19,16 @@ 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; }
[Required]
public string Number { get; set; } = String.Empty;
public string Number { get; set; } = string.Empty;
[Required]
public string CVC { get; set; }
public string CVC { get; set; } = string.Empty;
[Required]
public DateTime Period { get; set; } = DateTime.Now;
@ -56,6 +57,7 @@ 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

View File

@ -18,7 +18,7 @@ namespace BankYouBankruptDatabaseImplement.Models
[Required]
public int CardId { get; set; }
public virtual Card Card { get; set; } = new();
public virtual Card Card { get; set; }
[Required]
public int Sum { get; set; }

View File

@ -18,7 +18,7 @@ namespace BankYouBankruptDatabaseImplement.Models
[Required]
public int CardId { get; set; }
public virtual Card Card { get; set; } = new();
public virtual Card Card { get; set; }
[Required]
public int Sum { get; set; }
@ -49,10 +49,9 @@ namespace BankYouBankruptDatabaseImplement.Models
{
Id = model.Id,
CardId = model.CardId,
Card = context.Cards.First(x => x.Id == model.CardId),
Sum = model.Sum,
DateOpen = model.DateOpen,
Status = model.Status
Status = StatusEnum.Открыта
};
}