Coursework_ComputerStore_Li.../ComputerStoreContracts/ViewModels/PCViewModel.cs

40 lines
1.2 KiB
C#
Raw Normal View History

2023-05-17 17:57:25 +04:00
using ComputerStoreContracts.BindingModels;
using ComputerStoreDataModels.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerStoreContracts.ViewModels
{
public class PCViewModel : IPCModel
{
public int ID { get; set; }
[DisplayName("PC's name")]
public string Name { get; set; } = string.Empty;
[DisplayName("PC's price")]
public double Price { get; set; }
public int EmployeeID { get; set; }
[DisplayName("Employee's username")]
public string EmployeeUsername { get; set; } = string.Empty;
[DisplayName("Request ID")]
public int RequestID { get; set; }
2023-05-17 17:57:25 +04:00
public Dictionary<int, (IComponentModel Component, int Quantity)> PCComponents { get; set; } = new();
[JsonConstructor]
public PCViewModel(Dictionary<int, (ComponentBindingModel Component, int Quantity)> PCComponents)
{
this.PCComponents = PCComponents.ToDictionary(x => x.Key, x => (x.Value.Component as IComponentModel, x.Value.Quantity));
}
public PCViewModel() { }
}
}