public void RemoveDependent(Guid id) { if (Dependents.Any(preexistingDependent => preexistingDependent.Id == id)) { Dependents = Dependents.Where(d => d.Id != id); PublishDomainEvent(new RemoveEmployeeDependent { Employee = Id, Dependent = id }); } }
internal string ReportMissingDependencies(ICollection <string> existing) { var builder = new StringBuilder(); if (String.IsNullOrEmpty(FileName)) { builder.Append("warning N0001 : "); } else { builder.AppendFormat("{0} : warning N0001 : ", FileName); } builder.AppendFormat("{0} is pending. Missing dependencies: ", Name); foreach (string depend in Dependents.Where(depend => !existing.Contains(depend))) { builder.Append(depend).Append(", "); } return(builder.ToString()); }
public byte[] Generate() { using (MemoryStream memStream = new MemoryStream()) { Document document = new Document(PageSize.A4, 25, 25, 30, 30); PdfWriter writer = PdfWriter.GetInstance(document, memStream); document.Open(); PdfPTable topSection = new PdfPTable(2); topSection.DefaultCell.Border = Rectangle.NO_BORDER; // Full Name var fullNamePhrase = new Phrase(); topSection.DefaultCell.Border = Rectangle.NO_BORDER; fullNamePhrase.Add(new Chunk("Name: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16))); fullNamePhrase.Add(new Chunk(FullName, FontFactory.GetFont(FontFactory.HELVETICA, 16))); PdfPCell fullNameCell = new PdfPCell(fullNamePhrase); fullNameCell.Border = Rectangle.NO_BORDER; topSection.AddCell(fullNameCell); // Base Salary var annualSalaryPhrase = new Phrase(); annualSalaryPhrase.Add(new Chunk("Base Salary: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16))); annualSalaryPhrase.Add(new Chunk("$" + AnnualSalary.ToString("f2"), FontFactory.GetFont(FontFactory.HELVETICA, 16))); PdfPCell baseSalaryCell = new PdfPCell(annualSalaryPhrase); baseSalaryCell.Border = Rectangle.NO_BORDER; topSection.AddCell(baseSalaryCell); document.Add(topSection); PdfPTable dependentSection = new PdfPTable(1); dependentSection.SpacingBefore = 20f; dependentSection.DefaultCell.Border = Rectangle.NO_BORDER; PdfPCell headerLabel = new PdfPCell(new Phrase(new Chunk("Dependents", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16)))); headerLabel.Border = Rectangle.NO_BORDER; dependentSection.AddCell(headerLabel); foreach (var dependent in Dependents.Where(x => !string.IsNullOrEmpty(x))) { PdfPCell dependentCell = new PdfPCell(new Phrase(new Chunk("-" + dependent, FontFactory.GetFont(FontFactory.HELVETICA, 14)))); dependentCell.Border = Rectangle.NO_BORDER; dependentSection.AddCell(dependentCell); } document.Add(dependentSection); PdfPTable bottomSection = new PdfPTable(1); bottomSection.SpacingBefore = 40f; bottomSection.DefaultCell.Border = Rectangle.NO_BORDER; PdfPTable detailsTable = new PdfPTable(2); detailsTable.DefaultCell.Border = Rectangle.NO_BORDER; PdfPCell discountHeaderCell = new PdfPCell(new Phrase(new Chunk("Dependents", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 14)))); discountHeaderCell.Colspan = 2; detailsTable.AddCell(discountHeaderCell); foreach (var discount in Discounts) { PdfPCell discountItemCell = new PdfPCell(new Phrase(new Chunk(discount, FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12)))); discountItemCell.Colspan = 2; detailsTable.AddCell(discountItemCell); } detailsTable.AddCell(new PdfPCell(new Phrase(new Chunk("Total: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 14))))); detailsTable.AddCell(new PdfPCell(new Phrase(new Chunk(Total.ToString("f2"), FontFactory.GetFont(FontFactory.HELVETICA, 14))))); detailsTable.AddCell(new PdfPCell(new Phrase(new Chunk("Total Per Check: ", FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 14))))); detailsTable.AddCell(new PdfPCell(new Phrase(new Chunk(TotalPerCheck.ToString("f2"), FontFactory.GetFont(FontFactory.HELVETICA, 14))))); bottomSection.AddCell(new PdfPCell(detailsTable)); document.Add(bottomSection); PdfContentByte canvas = writer.DirectContent; PieChart pieChart = new PieChart(new double[] { Total, TotalEmployeeBenefitCost, TotalDependentsBenefitCost }, new[] { "Total After Benefits", "Employee Benefits", "Employee Dependent Benefits" }); canvas.DrawPieChart(pieChart, 300, 300, 100); document.Close(); return(memStream.ToArray()); } }