Exemplo n.º 1
0
        public IHttpActionResult UpdateUsersStatus([FromBody] TimeSpan isNowOfflineTimeLimit)
        {
            s_log.LogInfo($@"{nameof(UpdateUsersStatus)}({isNowOfflineTimeLimit}) is called");
            Console.WriteLine($@"{nameof(UpdateUsersStatus)}({isNowOfflineTimeLimit}) is called");

            var timeLimitToExceed = DateTimeOffset.Now - isNowOfflineTimeLimit;

            var notOfflineUsers = _userDataProvider.GetAllNotOfflineUsers();

            if (notOfflineUsers == null || notOfflineUsers.Count == 0)
            {
                return(Ok(false));
            }
            foreach (var user in notOfflineUsers)
            {
                if (user.LastActiveDate < timeLimitToExceed)
                {
                    var result = _userDataProvider.UpdateUserStatus(user.Id, 0);
                    if (result == 0)
                    {
                        return(Ok(false));
                    }
                }
            }
            return(Ok(true));
        }
Exemplo n.º 2
0
        private static void UpdateUserStatus()
        {
            var timeLimitToExceed = DateTimeOffset.Now - s_isNowOfflineTimeLimit;

            foreach (var user in s_userDataProvider.GetAllNotOfflineUsers())
            {
                if (user.LastActiveDate < timeLimitToExceed)
                {
                    s_userDataProvider.UpdateUserStatus(user.Id, 0);
                }
            }
        }