CourseWork_Bank/Bank/BankContracts/ViewModels/PurchaseViewModel.cs

39 lines
1.4 KiB
C#

using BankDataModels;
using System.ComponentModel;
using BankDataModels.ProxyModels;
using System.Text;
namespace BankContracts.ViewModels
{
public class PurchaseViewModel : IPurchaseModel
{
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)
{
break;
}
result.Append($"\n\t{i + 1}. {operation.Mark} {operation.Model} стоимостью {operation.Price}");
}
return result.ToString();
}
}
}