Пример #1
0
        public List <Notification> GetAllNotification(int signupId)
        {
            List <Notification> notifications = new List <Notification>();
            List <int>          idList        = notificationGateway.GetAllFriendList(signupId);

            foreach (int id in idList)
            {
                Person       person        = homeGateway.GetPersonInformation(id);
                List <Photo> profilePhotos = notificationGateway.GetAllProfilePhotoByID(id);
                foreach (Photo profilePhoto in profilePhotos)
                {
                    Notification n1 = new Notification();
                    n1.Type               = 1;
                    n1.TypeId             = profilePhoto.ID;
                    n1.OwnerId            = profilePhoto.SignupID;
                    n1.OwnerName          = person.Name;
                    n1.DateTime           = profilePhoto.DateTime;
                    n1.NotificationString = person.Name + " has uploaded a new profile Photo";
                    notifications.Add(n1);
                }
                List <Photo> coverPhotos = notificationGateway.GetAllCoverPhotoByID(id);
                foreach (Photo profilePhoto in coverPhotos)
                {
                    Notification n2 = new Notification();
                    n2.Type               = 2;
                    n2.TypeId             = profilePhoto.ID;
                    n2.OwnerId            = profilePhoto.SignupID;
                    n2.OwnerName          = person.Name;
                    n2.DateTime           = profilePhoto.DateTime;
                    n2.NotificationString = person.Name + " has uploaded a new cover Photo";
                    notifications.Add(n2);
                }
                List <PostInfo> postInfos = notificationGateway.GetAllPostInformationByID(id);
                foreach (PostInfo postInfo in postInfos)
                {
                    Notification n3 = new Notification();
                    n3.Type               = 3;
                    n3.TypeId             = postInfo.Id;
                    n3.OwnerId            = postInfo.SignUpID;
                    n3.OwnerName          = person.Name;
                    n3.DateTime           = postInfo.DateTime;
                    n3.NotificationString = person.Name + " has given a new post";
                    notifications.Add(n3);
                }
            }

            List <PostLike> postLikes = notificationGateway.GetPostLikeList(signupId);

            foreach (PostLike postLike in postLikes)
            {
                Notification n4 = new Notification();
                n4.Type               = 4;
                n4.TypeId             = postLike.PostID;
                n4.OwnerId            = postLike.SignupID;
                n4.OwnerName          = homeGateway.GetPersonInformation(postLike.SignupID).Name;
                n4.DateTime           = postLike.DateTime;
                n4.NotificationString = n4.OwnerName + " has given like on your post";
                notifications.Add(n4);
            }
            List <PostLike> postComment = notificationGateway.GetPostCommentList(signupId);

            foreach (PostLike postLike in postComment)
            {
                Notification n5 = new Notification();
                n5.Type               = 5;
                n5.TypeId             = postLike.PostID;
                n5.OwnerId            = postLike.SignupID;
                n5.OwnerName          = homeGateway.GetPersonInformation(postLike.SignupID).Name;
                n5.DateTime           = postLike.DateTime;
                n5.NotificationString = n5.OwnerName + " has given comment on your post";
                notifications.Add(n5);
            }
            List <PostLike> friendNotification = notificationGateway.GetAllFriendNotificationList(signupId);

            foreach (PostLike postLike in friendNotification)
            {
                Notification n6 = new Notification();
                n6.Type               = 6;
                n6.TypeId             = postLike.SignupID;
                n6.OwnerId            = postLike.SignupID;
                n6.OwnerName          = homeGateway.GetPersonInformation(postLike.SignupID).Name;
                n6.DateTime           = postLike.DateTime;
                n6.NotificationString = n6.OwnerName + " has become your friend";
                notifications.Add(n6);
            }
            List <PostLike> friendRequestNotification = notificationGateway.GetAllFriendRequestList(signupId);

            foreach (PostLike postLike in friendRequestNotification)
            {
                Notification n7 = new Notification();
                n7.Type               = 7;
                n7.TypeId             = postLike.SignupID;
                n7.OwnerId            = postLike.SignupID;
                n7.OwnerName          = homeGateway.GetPersonInformation(postLike.SignupID).Name;
                n7.DateTime           = postLike.DateTime;
                n7.NotificationString = n7.OwnerName + " has given you a Friend Request";
                notifications.Add(n7);
            }
            List <PostLike> mutualFriendPostLikeNotification = notificationGateway.GetMutualPostLikeList(idList);

            foreach (PostLike postLike in mutualFriendPostLikeNotification)
            {
                Notification n8 = new Notification();
                n8.Type               = 8;
                n8.TypeId             = postLike.PostID;
                n8.OwnerId            = postLike.SignupID;
                n8.OwnerName          = homeGateway.GetPersonInformation(postLike.SignupID).Name;
                n8.DateTime           = postLike.DateTime;
                n8.NotificationString = homeGateway.GetPersonInformation(postLike.SignupID).Name + " has Liked " + homeGateway.GetPersonInformation(postLike.OwenerID).Name + "'s Post";
                notifications.Add(n8);
            }
            List <PostLike> mutualFriendPostCommentNotification = notificationGateway.GetMutualPostCommentList(idList);

            foreach (PostLike postLike in mutualFriendPostCommentNotification)
            {
                Notification n9 = new Notification();
                n9.Type               = 9;
                n9.TypeId             = postLike.PostID;
                n9.OwnerId            = postLike.SignupID;
                n9.OwnerName          = homeGateway.GetPersonInformation(postLike.SignupID).Name;
                n9.DateTime           = postLike.DateTime;
                n9.NotificationString = homeGateway.GetPersonInformation(postLike.SignupID).Name + " has Comment on " + homeGateway.GetPersonInformation(postLike.OwenerID).Name + "'s Post";
                notifications.Add(n9);
            }
            notifications = notifications.OrderByDescending(e => e.DateTime).ThenByDescending(e => e.DateTime).ToList();
            //notifications = (from e in notifications
            //             orderby e.DateTime, e.DateTime
            //             select e).ToList();


            return(notifications);
        }
 public List <Photo> GetAllCoverPhotoByID(int signupID)
 {
     return(notificationGateway.GetAllCoverPhotoByID(signupID));
 }