using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CaseAccountingContracts.BindingModels
{
    public class DealBindingModel : IDealModel
    {
        public string Subject { get; set; } = string.Empty;

        public string Responsibilities { get; set; } = string.Empty;

        public DateTime Date { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);

        public int UserId { get; set; }

        public int Id { get; set; }

        public Dictionary<int, ICaseModel> Cases { get; set; } = new();

        public List<CaseViewModel> CaseViewModels { get; set; } = new();

        public Dictionary<int, IContractModel> Contracts { get; set; } = new();

        public List<ContractViewModel> ContractViewModels { get; set; } = new();

        public DealBindingModel() { }

        [JsonConstructor]
        public DealBindingModel(Dictionary<int, CaseViewModel> Cases, Dictionary<int, ContractViewModel> Contracts)
        {
            this.Cases = Cases.ToDictionary(x => x.Key, x => (ICaseModel)x.Value);
            this.Contracts = Contracts.ToDictionary(x => x.Key, x => (IContractModel)x.Value);
        }
    }
}
