You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
using System.Collections.Generic;
|
|
using PaymentServer.Models;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace PaymentServer.Models
|
|
{
|
|
public class ContractData
|
|
{
|
|
public Dictionary<string, List<VendorPayment>> contracts = new Dictionary<string, List<VendorPayment>>();
|
|
|
|
public void AddPayments(List<VendorPayment> vendorPayments)
|
|
{
|
|
List<string> existingContracts = new List<string>(this.contracts.Keys);
|
|
|
|
foreach (VendorPayment payment in vendorPayments)
|
|
{
|
|
if (existingContracts.Contains(payment.contractNumber))
|
|
{
|
|
this.contracts[payment.contractNumber].Add(payment);
|
|
}
|
|
else
|
|
{
|
|
this.contracts.Add(payment.contractNumber, new List<VendorPayment> { payment });
|
|
existingContracts.Add(payment.contractNumber);
|
|
}
|
|
}
|
|
Console.WriteLine(this.contracts.Count);
|
|
}
|
|
public string ToJson()
|
|
{
|
|
return JsonConvert.SerializeObject(this.contracts.Values);
|
|
}
|
|
}
|
|
}
|
|
|