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 car = OperationViewModels[i];
if (car == null)
{
break;
}
result.Append($"\n\t{i + 1}. {car.Mark} {car.Model} стоимостью {car.Price}");
}
return result.ToString();
}
}
}