public List <POST> GetUserTimeline(string username) { var listOfPosts = new List <POST>(); using (var context = new PastebookEntities()) { listOfPosts = context.POSTs.Include("LIKEs").Include("COMMENTs").Include("USER").Include("COMMENTs.USER").Include("LIKEs.USER").Where(p => p.USER1.USER_NAME == username).OrderByDescending(d => d.CREATED_DATE).Take(100).ToList(); } return(listOfPosts); }
public int GetProfileOwnerID(int postID) { POST post = new POST(); using (var context = new PastebookEntities()) { post = context.POSTs.FirstOrDefault(p => p.ID == postID); } return(post.POSTER_ID); }
public POST GetPost(int postID) { POST post = new POST(); using (var context = new PastebookEntities()) { post = context.POSTs.Include("LIKEs").Include("COMMENTs").Include("USER").Include("USER1").Include("COMMENTs.USER").Include("LIKEs.USER").FirstOrDefault(p => p.ID == postID); } return(post); }
public List <USER> GetListOfFriends(int id) { var listOfFriendsInformation = new List <USER>(); using (var context = new PastebookEntities()) { listOfFriendsInformation = context.FRIENDs.Include("USER1").Include("USER").Where(f => f.USER_ID == id && f.REQUEST == "N").Select(f => f.USER).ToList(); } return(listOfFriendsInformation); }
public List <POST> GetUserNewsFeed(List <int> listOfFriendsID) { var listOfPosts = new List <POST>(); using (var context = new PastebookEntities()) { listOfPosts = context.POSTs.Include("LIKEs").Include("COMMENTs").Include("USER").Include("USER1").Include("COMMENTs.USER").Include("LIKEs.USER").Where(p => listOfFriendsID.Contains(p.POSTER_ID)).OrderByDescending(d => d.CREATED_DATE).ToList(); } return(listOfPosts); }
public FRIEND GetFriendRelationship(int id) { FRIEND getSpecificFriend = new FRIEND(); using (var context = new PastebookEntities()) { getSpecificFriend = context.FRIENDs.FirstOrDefault(f => f.ID == id); } return(getSpecificFriend); }
public FRIEND GetPendingAndApprovedFriends(int userID, int friendID) { var friend = new FRIEND(); using (var context = new PastebookEntities()) { friend = context.FRIENDs.Include("USER1").Include("USER").FirstOrDefault(f => (f.USER_ID == userID && f.FRIEND_ID == friendID) || (f.USER_ID == friendID && f.FRIEND_ID == userID)); } return(friend); }
public List <FRIEND> GetPendingFriends(int id) { var listOfFriendsInformation = new List <FRIEND>(); using (var context = new PastebookEntities()) { listOfFriendsInformation = context.FRIENDs.Include("USER1").Where(f => f.FRIEND_ID == id && f.REQUEST == "Y").ToList(); } return(listOfFriendsInformation); }
public List <int> GetListOfFriendsID(int id) { List <int> listOfFriendsID = new List <int>(); using (var context = new PastebookEntities()) { listOfFriendsID = context.FRIENDs.Where(f => f.USER_ID == id && f.REQUEST == "N").Select(f => f.FRIEND_ID).ToList(); } return(listOfFriendsID); }
public List <REF_COUNTRY> GetCountryList() { var countryList = new List <REF_COUNTRY>(); using (var context = new PastebookEntities()) { countryList = context.REF_COUNTRY.ToList(); } return(countryList); }
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); }
/// <summary> /// This method checks the database if the username was already existing. /// </summary> /// <param name="username">Username that is inputted by the user.</param> /// <returns>True if the username exists, false if it is available.</returns> public bool CheckUsername(string username) { bool result = false; using (var context = new PastebookEntities()) { result = context.USERs.Any(u => u.USER_NAME == username); } return(result); }
/// <summary> /// This method checks the database if the email address was already existing. /// </summary> /// <param name="email">Email Address that is inputted by the user.</param> /// <returns>True if the email address exists, false if it is available.</returns> public bool CheckEmail(string email) { bool result = false; using (var context = new PastebookEntities()) { result = context.USERs.Any(u => u.EMAIL_ADDRESS == email); } return(result); }
public List <NOTIFICATION> GetListOfNotifications(int id) { List <NOTIFICATION> listOfNotifications = new List <NOTIFICATION>(); using (var context = new PastebookEntities()) { listOfNotifications = context.NOTIFICATIONs.Include("USER").Include("USER1").Where(n => n.RECEIVER_ID == id).OrderByDescending(n => n.CREATED_DATE).ToList(); } return(listOfNotifications); }
/// <summary> /// This method get the user from the database. /// </summary> /// <param name="email">Email that is inputted by the user.</param> /// <returns>User information.</returns> public USER GetUser(string email, string username) { var selectedUser = new USER(); using (var context = new PastebookEntities()) { selectedUser = context.USERs.Include("REF_COUNTRY").FirstOrDefault(u => u.EMAIL_ADDRESS == email || u.USER_NAME == username); } return(selectedUser); }
public NOTIFICATION GetNotificationForFriendRequest(FRIEND friend) { NOTIFICATION notification = new NOTIFICATION(); using (var context = new PastebookEntities()) { notification = context.NOTIFICATIONs.FirstOrDefault(n => n.SENDER_ID == friend.USER_ID && n.RECEIVER_ID == friend.FRIEND_ID && n.NOTIF_TYPE == "F"); } return(notification); }
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); }
public List <NOTIFICATION> GetListOfNotSeenNotifications(int id) { List <NOTIFICATION> listOfNotifications = new List <NOTIFICATION>(); using (var context = new PastebookEntities()) { listOfNotifications = context.NOTIFICATIONs.Include("USER").Include("USER1").Where(n => n.RECEIVER_ID == id && n.SEEN == "N").ToList(); } return(listOfNotifications); }
public int GetCountOfNotSeenNotifications(int id) { int count = 0; using (var context = new PastebookEntities()) { count = context.NOTIFICATIONs.Include("USER").Include("USER1").Where(n => n.RECEIVER_ID == id && n.SEEN == "N").ToList().Count; } return(count); }
public int Create(T items) { int result = 0; using (var context = new PastebookEntities()) { context.Entry(items).State = EntityState.Added; result = context.SaveChanges(); } return(result); }
public List <USER> GetListOfUsers(string name, int id) { List <USER> listOfUsers = new List <USER>(); using (var context = new PastebookEntities()) { //http://stackoverflow.com/questions/5676040/search-two-columns-in-linq-to-sql listOfUsers = (from user in context.USERs let fullname = user.FIRST_NAME + " " + user.LAST_NAME where fullname == name || user.FIRST_NAME == name || user.LAST_NAME == name select user).ToList(); } return(listOfUsers); }