public Invoice CreateInvoice(int clientId, int year, int month) { var linesInvoices = InvoicesFor(repository.GetClientUsageDetails(clientId, year, month)); return(new Invoice { StartDate = new DateTime(year, month, 1), EndDate = new DateTime(year, month, 1).AddMonths(1), LineInvoices = linesInvoices, TotalPrice = linesInvoices.Sum(i => i.TotalPrice), AdditionalPrice = linesInvoices.Sum(i => i.OutOfPackage.TotalAdditionalPrice) }); }