Пример #1
0
        private static UserInfo userToUserInfo(Community_ASPNETUser user)
        {
            var userInfo = new UserInfo();

            userInfo.Name                = user.name;
            userInfo.Email               = user.Email;
            userInfo.LastLogin           = latestLogin(user);
            userInfo.NrOfLoginsLastMonth = numberOfLogins(user);
            userInfo.TotalMessages       = numberOfMsg(user);
            userInfo.NrOfUnreadMessages  = numberOfUnreadMsg(user);
            userInfo.NrOfDeletedMessages = user.numberOfDeletedMessages;

            var groups = new List <GroupInfo>();

            foreach (var g in user.UserGroups)
            {
                var gi = new GroupInfo();
                gi.Id   = g.Group.Id;
                gi.Name = g.Group.Name;
            }
            userInfo.Groups = groups;

            userInfo.NrOfReadMessages = userInfo.TotalMessages - userInfo.NrOfUnreadMessages;

            return(userInfo);
        }
Пример #2
0
        private static int numberOfUnreadMsg(Community_ASPNETUser user)
        {
            int unread = 0;

            foreach (var m in user.Messages)
            {
                if (m.IsRead == false)
                {
                    unread++;
                }
            }
            return(unread);
        }
Пример #3
0
        private static int numberOfLogins(Community_ASPNETUser user)
        {
            int logins = 0;

            foreach (var l in user.LoginLogs)
            {
                if (l.Timestamp.Month == DateTime.Now.Month)
                {
                    logins++;
                }
            }
            return(logins);
        }
Пример #4
0
        private static DateTime latestLogin(Community_ASPNETUser user)
        {
            DateTime latest = user.LoginLogs.First().Timestamp;

            foreach (var time in user.LoginLogs)
            {
                DateTime check = time.Timestamp;
                if (DateTime.Compare(latest, check) < 0)
                {
                    latest = check;
                }
            }

            return(latest);
        }
Пример #5
0
 public static void RemoveUser(Community_ASPNETUser user)
 {
     UserDAL.DeleteUser(user);
 }
Пример #6
0
 public static void UpdateUser(Community_ASPNETUser user)
 {
     UserDAL.UpdateUser(user);
 }
Пример #7
0
        public static String GetUserIdString(String email)
        {
            Community_ASPNETUser user = UserDAL.GetUserWithEmail(email);

            return(user.Id);
        }
Пример #8
0
 private static int numberOfMsg(Community_ASPNETUser user)
 {
     return(user.Messages.Count());
 }
Пример #9
0
 public static void AddUser(Community_ASPNETUser user)
 {
     UserDAL.AddUserToDB(user);
 }