public static object GetTransactionGroupOrderByValue(TransactionGroup transactionGroup, TransactionGroupOrder orderBy) { switch (orderBy) { case TransactionGroupOrder.Agrupador: var groupBy = transactionGroup.Parent.GroupByDefinition.GroupBy; if (groupBy == TransactionGroupBy.DateDay) return DateTime.ParseExact(transactionGroup.Key.ToString(), "yyyy/MM/dd", CultureInfo.InvariantCulture); else if (groupBy == TransactionGroupBy.DateMonth) return DateTime.ParseExact(transactionGroup.Key.ToString() + "/01", "yyyy/MM/01", CultureInfo.InvariantCulture); else if (groupBy == TransactionGroupBy.DateMonth) return DateTime.ParseExact(transactionGroup.Key.ToString() + "/01/01", "yyyy/01/01", CultureInfo.InvariantCulture); return transactionGroup.Key; case TransactionGroupOrder.Total: return transactionGroup.Total; case TransactionGroupOrder.TransactionCount: return transactionGroup.Count; } return null; }
public Expression<Func<TransactionGroup, object>> GetOrderByGroupExpression(TransactionGroupOrder orderBy, out string orderByName) { switch (orderBy) { case TransactionGroupOrder.Agrupador: orderByName = "Agrupador"; break; case TransactionGroupOrder.Total: orderByName = "Total"; break; case TransactionGroupOrder.TransactionCount: orderByName = "Qtd. de transações"; break; default: orderByName = "Nenhum"; break; } return f => GetTransactionGroupOrderByValue(f, orderBy); }