private List <TrafficOnMainPage> GetTrafficListForTag(Account tag, Period period) { return((from t in _db.TransWithTags where period.ContainsAndTimeWasChecked(t.Timestamp) && t.Tags.Contains(tag) join r in _db.CurrencyRates on new { t.Timestamp.Date, Currency = t.Currency.GetValueOrDefault() } equals new { r.BankDay.Date, r.Currency } into g from rate in g.DefaultIfEmpty() select new TrafficOnMainPage() { Timestamp = t.Timestamp, Amount = t.AmountForTag(tag, t.Currency), Currency = t.Currency.GetValueOrDefault(), Rate = rate?.Rate ?? 0, Comment = t.Comment }).OrderBy(t => t.Timestamp).ToList()); }
private List <TrafficOnMainPage> GetTrafficWhereMyAccountIsFirstOrOnly(Account account, Period period) { return((from t in _db.TransWithTags where period.ContainsAndTimeWasChecked(t.Timestamp) && t.MyAccount.Is(account.Name) join r in _db.CurrencyRates on new { t.Timestamp.Date, Currency = t.Currency.GetValueOrDefault() } equals new { r.BankDay.Date, r.Currency } into g from rate in g.DefaultIfEmpty() select new TrafficOnMainPage() { Timestamp = t.Timestamp, Amount = t.AmountForAccount(account, t.Currency), Currency = t.Currency.GetValueOrDefault(), Rate = rate?.Rate ?? 0, Comment = t.Comment }).ToList()); }
private IEnumerable <TrafficOnMainPage> GetTrafficWhereMyAccountIsSecond(Account account, Period period) { return(from t in _db.TransWithTags where period.ContainsAndTimeWasChecked(t.Timestamp) && t.MySecondAccount != null && t.MySecondAccount.Is(account.Name) join r in _db.CurrencyRates on new { t.Timestamp.Date, Currency = t.CurrencyOfSecondAccount() } equals new { r.BankDay.Date, r.Currency } into g from rate in g.DefaultIfEmpty() select new TrafficOnMainPage() { Timestamp = t.Timestamp, Amount = t.AmountForAccount(account, t.CurrencyOfSecondAccount()), Currency = t.CurrencyOfSecondAccount(), Rate = rate?.Rate ?? 0, Comment = t.Comment }); }