Exemple #1
0
        public bool UnlikePost(LIKE like)
        {
            bool returnValue = false;

            returnValue = likeRepo.Remove(lke => lke.POST_ID == like.POST_ID && lke.LIKE_BY == like.LIKE_BY);
            notifManager.RemoveLikeNotification(like.POST_ID, like.LIKE_BY);
            return(returnValue);
        }
Exemple #2
0
        public static bool AddLikes(int bookid)
        {
            LIKE like = new LIKE()
            {
                USERID = (new SessionHandler().AuthenticatedUser().USERID),
                BOOKID = bookid
            };

            return(Service.AddLike(like));
        }
        public NOTIFICATION GetNotificationForLike(LIKE like)
        {
            NOTIFICATION notification = new NOTIFICATION();

            using (var context = new PastebookEntities())
            {
                notification = context.NOTIFICATIONs.FirstOrDefault(n => n.POST_ID == like.POST_ID && n.SENDER_ID == like.LIKED_BY && n.NOTIF_TYPE == "L");
            }

            return(notification);
        }
Exemple #4
0
        public LIKE GetLike(LIKE like)
        {
            LIKE specificLike = new LIKE();

            using (var context = new PastebookEntities())
            {
                specificLike = context.LIKEs.FirstOrDefault(l => l.LIKED_BY == like.LIKED_BY && l.POST_ID == like.POST_ID);
            }

            return(specificLike);
        }
 public bool AddLike(LIKE like)
 {
     try
     {
         dataAccess.LIKEs.InsertOnSubmit(like);
         dataAccess.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #6
0
        public int LikePost(int postID, int userID, string status)
        {
            GenericDataAccess <LIKE>         dataAccessLike         = new GenericDataAccess <LIKE>();
            GenericDataAccess <NOTIFICATION> dataAccessNotification = new GenericDataAccess <NOTIFICATION>();
            int result;
            int posterID = postDataAccess.GetProfileOwnerID(postID);

            var like = new LIKE()
            {
                LIKED_BY = userID,
                POST_ID  = postID
            };

            if (status == "like")
            {
                result = dataAccessLike.Create(like);

                if (result == 1 && userID != posterID)
                {
                    NOTIFICATION notification = new NOTIFICATION()
                    {
                        NOTIF_TYPE   = "L",
                        POST_ID      = postID,
                        RECEIVER_ID  = posterID,
                        SENDER_ID    = userID,
                        CREATED_DATE = DateTime.Now,
                        SEEN         = "N"
                    };

                    dataAccessNotification.Create(notification);
                }
            }
            else
            {
                result = dataAccessLike.Delete(likeDataAccess.GetLike(like));

                if (result == 1 && userID != posterID)
                {
                    dataAccessNotification.Delete(notificationDataAccess.GetNotificationForLike(like));
                }
            }

            return(result);
        }
        public bool RemoveLike(int userid, int bookid)
        {
            try
            {
                LIKE like = dataAccess.LIKEs.FirstOrDefault(lk => lk.USERID == userid && lk.BOOKID == bookid);

                if (like == null)
                {
                    return(false);
                }

                dataAccess.LIKEs.DeleteOnSubmit(like);
                dataAccess.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #8
0
        public bool LikePost(LIKE like, int postOwnerID)
        {
            bool returnValue = false;
            var  getLike     = likeRepo.Get(x => x.POST_ID == like.POST_ID && x.LIKE_BY == like.LIKE_BY);

            if (getLike == null)
            {
                returnValue = likeRepo.Add(like);

                if (postOwnerID != like.LIKE_BY)
                {
                    notifManager.AddNotification(new NOTIFICATION()
                    {
                        RECEIVER_ID = postOwnerID,
                        SEEN        = "N",
                        SENDER_ID   = like.LIKE_BY,
                        NOTIF_TYPE  = "L",
                        POST_ID     = like.POST_ID
                    });
                }
            }

            return(returnValue);
        }
 WHERE ([Id] LIKE @text OR [BookName] LIKE @text OR [Author] LIKE @text) {(getAll ? string.Empty : (availableOnly ? " AND [Borrowed] = 0 " : " AND [Borrowed] = 1 "))}