示例#1
0
        public override USER Get(Expression <Func <USER, bool> > where)
        {
            USER user = new USER();

            using (var context = new DB_PASTEBOOKEntities())
            {
                user = context.USERs.Include("REF_COUNTRY").Where(where).FirstOrDefault();
            }

            return(user);
        }
示例#2
0
        public virtual string Get(Expression <Func <C, bool> > where, Func <C, string> selectProperty)
        {
            string returnValue = string.Empty;

            using (var context = new DB_PASTEBOOKEntities())
            {
                returnValue = context.Set <C>().Where(where).Select(selectProperty).FirstOrDefault();
            }

            return(returnValue);
        }
示例#3
0
        public bool CheckIfUserNameExist(string userName)
        {
            bool returnValue = false;

            using (var context = new DB_PASTEBOOKEntities())
            {
                returnValue = context.USERs.Any(user => user.USER_NAME == userName);
            }

            return(returnValue);
        }
示例#4
0
        public bool CheckIfEmailExist(string email)
        {
            bool returnValue = false;

            using (var context = new DB_PASTEBOOKEntities())
            {
                returnValue = context.USERs.Any(user => user.EMAIL_ADDRESS == email);
            }

            return(returnValue);
        }
示例#5
0
        public virtual List <C> GetAll()
        {
            List <C> getAll = new List <C>();

            using (var context = new DB_PASTEBOOKEntities())
            {
                getAll = context.Set <C>().AsNoTracking().ToList <C>();
            }

            return(getAll);
        }
示例#6
0
        public virtual C Get(Expression <Func <C, bool> > where)
        {
            C item = null;

            using (var context = new DB_PASTEBOOKEntities())
            {
                item = context.Set <C>().Where(where).FirstOrDefault();
            }

            return(item);
        }
示例#7
0
        public virtual bool Update(C item)
        {
            bool returnValue = false;

            using (var context = new DB_PASTEBOOKEntities())
            {
                context.Entry(item).State = EntityState.Modified;
                returnValue = context.SaveChanges() != 0;
            }

            return(returnValue);
        }
示例#8
0
        public virtual List <C> GetList(Expression <Func <C, bool> > where)
        {
            List <C> getList = new List <C>();

            using (var context = new DB_PASTEBOOKEntities())
            {
                getList = context.Set <C>().AsNoTracking()
                          .Where(where).ToList();
            }

            return(getList);
        }
示例#9
0
        public virtual bool Remove(Expression <Func <C, bool> > where)
        {
            bool returnValue = false;

            using (var context = new DB_PASTEBOOKEntities())
            {
                var item = context.Set <C>().Where <C>(where).FirstOrDefault();
                context.Entry(item).State = EntityState.Deleted;
                returnValue = context.SaveChanges() != 0;
            }

            return(returnValue);
        }
示例#10
0
        public override List <FRIEND> GetList(Expression <Func <FRIEND, bool> > where)
        {
            List <FRIEND> friends = new List <FRIEND>();

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    friends = context.FRIENDs.Include("USER").Include("USER1").Where(where).ToList();
                }
            }
            catch
            {
                return(null);
            }
            return(friends);
        }
示例#11
0
        public int CountLikeCommentNotification(int userID)
        {
            int returnValue = 0;

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    returnValue = context.NOTIFICATIONs.Where(notif => notif.RECEIVER_ID == userID && notif.NOTIF_TYPE != "F" && notif.SEEN == "N").ToList().Count();
                }
            }
            catch
            {
                return(returnValue);
            }
            return(returnValue);
        }
示例#12
0
        public List <LIKE> GetLikes(int postID)
        {
            List <LIKE> postLikes = null;

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    postLikes = context.LIKEs.Include("USER").Where(lke => lke.POST_ID == postID).ToList();
                }
            }
            catch
            {
                return(postLikes);
            }
            return(postLikes);
        }
示例#13
0
        public bool CheckIfLikeExist(LIKE like)
        {
            bool returnValue = false;

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    returnValue = context.LIKEs.Where(lke => lke.POST_ID == like.POST_ID).Any(lke => lke.LIKE_BY == like.LIKE_BY);
                }
            }
            catch
            {
                return(returnValue);
            }
            return(returnValue);
        }
示例#14
0
        public string Get(int id)
        {
            string country = string.Empty;

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    country = context.REF_COUNTRY.Where(cntry => cntry.ID == id).Select(cntry => cntry.Country).FirstOrDefault();
                }
            }
            catch
            {
                return(country);
            }
            return(country);
        }
示例#15
0
        public List <REF_COUNTRY> GetAll()
        {
            List <REF_COUNTRY> countryList = null;

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    countryList = context.REF_COUNTRY.ToList();
                }
            }
            catch
            {
                return(countryList);
            }
            return(countryList);
        }
示例#16
0
        public override List <NOTIFICATION> GetList(Expression <Func <NOTIFICATION, bool> > where)
        {
            List <NOTIFICATION> notifications = new List <NOTIFICATION>();

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    notifications = context.NOTIFICATIONs.Include("USER1").Where(where).OrderByDescending(notif => notif.CREATED_DATE).ToList();
                }
            }
            catch
            {
                return(notifications);
            }
            return(notifications);
        }
示例#17
0
        public override POST Get(Expression <Func <POST, bool> > where)
        {
            POST post = new POST();

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    post = context.POSTs.Include("USER").Include("USER1").Include("LIKEs.USER").Include("COMMENTs.USER")
                           .Where(where).FirstOrDefault();
                }
            }
            catch
            {
                return(null);
            }
            return(post);
        }
示例#18
0
        public bool CheckIfFriendExist(int userID, int friendID)
        {
            bool returnValue = false;

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    returnValue = context.FRIENDs
                                  .Any(friend => (friend.USER_ID == userID && friend.FRIEND_ID == friendID) ||
                                       (friend.USER_ID == friendID && friend.FRIEND_ID == userID));
                }
            }
            catch
            {
                return(returnValue);
            }
            return(returnValue);
        }
示例#19
0
        public List <POST> GetUserTimelinePost(int userID)
        {
            List <POST> timelinePost = null;

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    timelinePost = context.POSTs.Include("USER").Include("USER1").Include("LIKEs").Include("COMMENTs.USER")
                                   .Where(pst => pst.PROFILE_OWNER_ID == userID || pst.POSTER_ID == userID).OrderByDescending(pst => pst.CREATED_DATE).Take(100).ToList();
                }
            }
            catch
            {
                return(timelinePost);
            }

            return(timelinePost);
        }
示例#20
0
        public List <POST> GetUserNewsFeedPost(List <int> friendsID)
        {
            List <POST> postList = new List <POST>();

            try
            {
                using (var context = new DB_PASTEBOOKEntities())
                {
                    postList = context.POSTs.Include("USER").Include("USER1").Include("LIKEs").Include("COMMENTs.USER")
                               .Where(pst => friendsID.Contains(pst.POSTER_ID)).OrderByDescending(pst => pst.CREATED_DATE).ToList();
                }
            }
            catch
            {
                return(postList);
            }

            return(postList);
        }