using ComputerShopDataModels.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace ComputerShopContracts.ViewModels
{
	public class RequestViewModel : IRequestModel
	{
		[DisplayName("Номер")]
		public int Id { get; set; }

		public int UserId { get; set; }

		//id сборки
		public int? AssemblyId { get; set; }


		public IAssemblyModel? Assembly { get; set; }

		public Dictionary<int, IOrderModel> RequestOrders { get; set; } = new();

		[DisplayName("Дата оформления")]
		public DateTime DateRequest { get; set; } = DateTime.Now;

		[DisplayName("ФИО клиента")]
		public string ClientFIO { get; set; } = string.Empty;

		public RequestViewModel() { }

		[JsonConstructor]
		public RequestViewModel(Dictionary<int, OrderViewModel> requestOrders, AssemblyViewModel assembly)
		{
			this.RequestOrders = requestOrders.ToDictionary(x => x.Key, x => x.Value as IOrderModel);
			this.Assembly = assembly as IAssemblyModel;
		}
	}
}