Пример #1
0
        public AccountStatisticsModel GetAllTimeAccountStatistics(AccountStatisticsList allStatistics)
        {
            long accountId      = 0;
            var  updateDateTime = new DateTime();

            var accountStatisticsModel = allStatistics.StatisticsList.OrderByDescending(model => model.DateTimeUpdateStatistics).FirstOrDefault();

            if (accountStatisticsModel == null)
            {
                return(new AccountStatisticsModel
                {
                    CountReceivedFriends = allStatistics.StatisticsList.Sum(model => model.CountReceivedFriends),
                    CountRequestsSentToFriends =
                        allStatistics.StatisticsList.Sum(model => model.CountRequestsSentToFriends),
                    CountOrdersConfirmedFriends =
                        allStatistics.StatisticsList.Sum(model => model.CountOrdersConfirmedFriends),
                    CountOfWinksBack = allStatistics.StatisticsList.Sum(model => model.CountOfWinksBack),
                    AccountId = accountId,
                    CreateDateTime = DateTime.Now,
                    DateTimeUpdateStatistics = updateDateTime
                });
            }

            accountId      = accountStatisticsModel.AccountId;
            updateDateTime = accountStatisticsModel.DateTimeUpdateStatistics;

            return(new AccountStatisticsModel
            {
                CountReceivedFriends = allStatistics.StatisticsList.Sum(model => model.CountReceivedFriends),
                CountRequestsSentToFriends = allStatistics.StatisticsList.Sum(model => model.CountRequestsSentToFriends),
                CountOrdersConfirmedFriends = allStatistics.StatisticsList.Sum(model => model.CountOrdersConfirmedFriends),
                CountOfWinksBack = allStatistics.StatisticsList.Sum(model => model.CountOfWinksBack),
                AccountId = accountId,
                CreateDateTime = DateTime.Now,
                DateTimeUpdateStatistics = updateDateTime
            });
        }
Пример #2
0
 public AccountStatisticsModel GetLastHourAccountStatistics(AccountStatisticsList allStatistics)
 {
     return(allStatistics.StatisticsList.OrderByDescending(model => model.CreateDateTime).FirstOrDefault());
 }