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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }