Created
February 22, 2019 00:51
-
-
Save shawnweisfeld/741f884f5fc5f86e1ba63c26127dac6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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