decimal CalculateTotalPromoted(Receipt receipt, Promotion[] promotions) { string[] barcodes = promotions.Where(p => p.Type == "BUY_ONE_HUNDRED_CUT_FIFTY") .Select(p => p.BarCode) .ToArray(); decimal totalAfterPromoted = receipt.ReceiptItems.Where(r => barcodes.Contains(r.Product.Barcode)) .Select(r => (r.Total - r.Promoted)).Sum(); return (int)(totalAfterPromoted/100)*50; }