CourseWork_Bank/Bank/BankContracts/ViewModels/PurchaseViewModel.cs

39 lines
1.4 KiB
C#
Raw Normal View History

2024-04-28 21:34:43 +04:00
using BankDataModels;
using System.ComponentModel;
using BankDataModels.ProxyModels;
using System.Text;
namespace BankContracts.ViewModels
{
2024-04-28 21:34:43 +04:00
public class PurchaseViewModel : IPurchaseModel
{
2024-04-28 21:34:43 +04:00
public int Id { get; set; }
public int ClientId { get; set; }
[DisplayName("Логин клиента")]
public string ClientPhoneNumber { get; set; } = string.Empty;
[DisplayName("Дата Покупки")]
public DateOnly DatePurchase { get; set; } = DateOnly.FromDateTime(DateTime.Now);
public Dictionary<int, OperationByPurchaseModel> OperationsModel { get; set; } = new();
public List<CostViewModel> CostViewModels { get; set; } = new();
public List<OperationViewModel> OperationViewModels { get; set; } = new();
public override string ToString()
{
var result = new StringBuilder(
$"Сделка, созданная {DatePurchase}, включает в себя операции:");
for (int i = 0; i < OperationViewModels.Count; i++)
{
var operation = OperationViewModels[i];
if (operation == null)
2024-04-28 21:34:43 +04:00
{
break;
}
result.Append($"\n\t{i + 1}. {operation.Mark} {operation.Model} стоимостью {operation.Price}");
2024-04-28 21:34:43 +04:00
}
return result.ToString();
}
}
}