public void LogActivityCount(ProfileMessage profile, string account, LogType logtype)
        {
            var item = LogActivitySet.FirstOrDefault(x => x.Date == TodayText && account == x.Account);

            if (item == null)
            {
                LogActivitySet.Add(new LogActivityDto {
                    Date = TodayText, Account = account
                });
            }

            SaveChanges();
            item = LogActivitySet.First(x => x.Date == TodayText && account == x.Account);

            switch (logtype)
            {
            case LogType.AddedFriend:
                item.AddedFriendCount++;
                break;

            case LogType.MessageFriend:
                item.PostFriendCount++;
                break;

            case LogType.MessageToStranger:
                item.PostStrangerCount++;
                break;
            }
            SaveChanges();
        }
        public LogActivityDto[] GetDailyActivity(DateTime?dateTime = null, string account = null)
        {
            LogActivityDto[] logs = null;
            if (dateTime == null)
            {
                if (account == null)
                {
                    logs = LogActivitySet
                           .OrderByDescending(x => x.Id)
                           .Take(30)
                           .ToArray();
                }
                else
                {
                    logs = LogActivitySet
                           .Where(x => x.Account == account)
                           .OrderByDescending(x => x.Id)
                           .Take(30)
                           .ToArray();
                }
            }
            else
            {
                var dateText = dateTime?.ToString("dd'/'MM'/'yyyy");
                if (account == null)
                {
                    logs = LogActivitySet
                           .Where(x => x.Date == dateText)
                           .OrderByDescending(x => x.Id)
                           .ToArray();
                }
                else
                {
                    logs = LogActivitySet
                           .Where(x => x.Date == dateText && x.Account == account)
                           .OrderByDescending(x => x.Id)
                           .ToArray();
                }
            }

            return(logs.OrderByDescending(x => DateTime.Parse(x.Date)).ThenBy(x => x.Account).ToArray());
        }
 public int GetMessageToStragerCount(string account) => LogActivitySet.FirstOrDefault(x => x.Date == TodayText && x.Account == account)?.PostStrangerCount ?? 0;
 public int GetAddedFriendCount(string account) => LogActivitySet.FirstOrDefault(x => x.Date == TodayText && x.Account == account)?.AddedFriendCount ?? 0;