Skip to content

Instantly share code, notes, and snippets.

@mitchgollub
Created July 14, 2019 20:55
Show Gist options
  • Save mitchgollub/19df2b01115bc13273f249e1d4927e40 to your computer and use it in GitHub Desktop.
Save mitchgollub/19df2b01115bc13273f249e1d4927e40 to your computer and use it in GitHub Desktop.
c-sharp-and-csvs
foreach (var salesRep in salesReps)
{
var summary = new SalesSummary { SalesRep = salesRep };
var repTransactions = transactions.Where(x => x.SalesRep == salesRep);
summary.Y2DSold = repTransactions.Where(x => x.Date >= new DateTime(dateTimeNow.Year, 1, 1))
.Select(x => CalculateTransaction(x))
.Sum();
summary.M2DSold = repTransactions.Where(x => x.Date >= new DateTime(dateTimeNow.Year, dateTimeNow.Month, 1))
.Select(x => CalculateTransaction(x))
.Sum();
summary.Q2DSold = repTransactions.Where(x => GetQuarter(x.Date) == GetQuarter(dateTimeNow))
.Select(x => CalculateTransaction(x))
.Sum();
summary.I2DSold = repTransactions
.Select(x => CalculateTransaction(x))
.Sum();
salesSummaries.Add(summary);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment