Skip to content

Instantly share code, notes, and snippets.

@shawnweisfeld
Created February 22, 2019 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnweisfeld/741f884f5fc5f86e1ba63c26127dac6c to your computer and use it in GitHub Desktop.
Save shawnweisfeld/741f884f5fc5f86e1ba63c26127dac6c to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1
{
class Policy
{
public List<Unit> Units { get; set; }
}
class Unit
{
public string Type { get; set; }
public List<Coverage> Coverages { get; set; }
}
class Coverage
{
public string CoverageCode { get; set; }
}
class Program
{
static void Main(string[] args)
{
var p = new Policy()
{
Units = new List<Unit>()
{
new Unit()
{
Type = "OCx",
Coverages = new List<Coverage>()
{
new Coverage()
{
CoverageCode = "OCC"
}
}
}
}
};
var policyCoverages = p.Units.SelectMany(u => u.Coverages.Select(c => new { Unit = u, Coverage = c })).ToList();
if (!policyCoverages.Any(x => x.Unit.Type == "OC" && x.Coverage.CoverageCode == "OCC"))
{
Console.WriteLine("Policy must have at least one OC unit with an OCC coverage.");
}
else
{
Console.WriteLine("we are good");
}
Console.WriteLine("done");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment