/* * <summary>Gets a bubble_group by id</summary> * <param name="id"></param> * <returns>a bubble_groups object</returns> * <author>Andri Rafn</author> */ static public bubble_groups GetGroupById(int id) { var db = new VERK2015_H17Entities1(); bubble_groups group = (db.bubble_groups.ToList().Where(x => x.C_ID == id)).Single(); return(group); }
/* <summary></summary> * <param name="ID"></param> * <returns></returns> * <author></author> */ public static List <bubble_groups> SearchGroupByName(bubble_groups gr) { var db = new VERK2015_H17Entities1(); var groups = (from x in db.bubble_groups.Where(y => y.group_name.Contains(gr.group_name)) select x).ToList(); return(groups); }
/* <summary>Creates a group</summary> * <param name="group">bubble group model</param> * <returns>New group</returns> * <author>Sveinbjorn</author> */ static public bubble_groups CreateGroup(bubble_groups group) { var db = new VERK2015_H17Entities1(); db.bubble_groups.Add(group); db.SaveChanges(); return(group); }
/* <summary>Gets a list of posts in group</summary> * <param name="bubbleGroup">Group model</param> * <returns>List of posts in the group</returns> * <author>Sveinbjorn</author> */ static public List <posts> GetAllGroupPosts(bubble_groups bubbleGroup) { var db = new VERK2015_H17Entities1(); var groupPosts = (from x in db.posts.Where(y => y.FK_posts_bubble_groups == bubbleGroup.C_ID) select x).ToList(); return(groupPosts); }
public ActionResult GetGroupById(FormCollection collection) { if (!User.Identity.IsAuthenticated) { return(Json("No Authentication")); } bubble_groups group = GroupService.GetGroupById(Convert.ToInt32(collection["groupId"])); List <string> returnJson = new List <string>(); returnJson.Add(group.group_name); returnJson.Add(group.group_description); returnJson.Add(group.group_profile_image); return(Json(returnJson)); }
public void TestGetAllGroupPostForPrufuGroup() { // Arrange: var grpPrufuGroup = new bubble_groups { C_ID = 14, group_name = "PrufuGroup", }; // Act: var grpPosts = GroupService.GetAllGroupPosts(grpPrufuGroup); // Assert: Assert.AreEqual(1, grpPosts.Count); }
public ActionResult Create(FormCollection fc, HttpPostedFileBase contentImage) { bubble_groups bGroup = new bubble_groups(); bGroup.group_description = fc["group-description"]; bGroup.group_name = fc["group-name"]; bGroup.FK_bubble_groups_users = UserService.GetUserByEmail(User.Identity.Name).Id; if (contentImage != null) { bGroup.group_profile_image = FileUploadService.UploadImage(contentImage, "Groups"); } var newGroup = GroupService.CreateGroup(bGroup); return(RedirectToAction("Home", "Home"));; }
public ActionResult GetGroupPosts(FormCollection collection) { if (!User.Identity.IsAuthenticated) { return(Json("No Authentication")); } bubble_groups group = new bubble_groups(); group.C_ID = Convert.ToInt32(collection["groupId"]); List <posts> allPosts = GroupService.GetAllGroupPosts(group); var posterNames = (from post in allPosts select post.AspNetUsers.NickName).ToList(); var postBody = (from post in allPosts select post.content_text).ToList(); var profileImage = (from post in allPosts select post.AspNetUsers.profile_image).ToList(); var posterId = (from post in allPosts select post.AspNetUsers.Id).ToList(); var postId = (from post in allPosts select post.C_ID.ToString()).ToList(); var postLikeCount = (from post in allPosts select post.post_likes.Where(y => y.post_like == true).Count().ToString()).ToList(); var postBurstcount = (from post in allPosts select post.post_likes.Where(y => y.post_burst == true).Count().ToString()).ToList(); var postImage = (from post in allPosts select post.content_picture).ToList(); List <List <string> > returnJson = new List <List <string> >(); returnJson.Add(posterNames); returnJson.Add(postBody); returnJson.Add(profileImage); returnJson.Add(posterId); returnJson.Add(postId); returnJson.Add(postLikeCount); returnJson.Add(postBurstcount); returnJson.Add(postImage); return(Json(returnJson)); }
public ActionResult GetResults(FormCollection fc) { List <List <List <string> > > returnJson = new List <List <List <string> > >(); /* * [0] = Users * [1] = Groups * [2] = Events */ // Users List <List <string> > userInfo = new List <List <string> >(); AspNetUsers user = new AspNetUsers(); user.NickName = fc["search_string"]; var userSearchResults = SearchService.SearchUsersByName(user); var userNames = (from usr in userSearchResults select usr.NickName).ToList(); var userImages = (from usr in userSearchResults select usr.profile_image).ToList(); var userId = (from usr in userSearchResults select usr.Id).ToList(); userInfo.Add(userNames); userInfo.Add(userImages); userInfo.Add(userId); // Groups List <List <string> > groupInfo = new List <List <string> >(); bubble_groups bGroup = new bubble_groups(); bGroup.group_name = fc["search_string"]; var groupSearchResults = SearchService.SearchGroupByName(bGroup); var groupNames = (from grp in groupSearchResults select grp.group_name).ToList(); var groupImages = (from grp in groupSearchResults select grp.group_profile_image).ToList(); var groupId = (from grp in groupSearchResults select grp.C_ID.ToString()).ToList(); groupInfo.Add(groupNames); groupInfo.Add(groupImages); groupInfo.Add(groupId); // Events List <List <string> > eventInfo = new List <List <string> >(); events evnts = new events(); evnts.event_name = fc["search_string"]; var eventSearchResults = SearchService.SearchEventsByName(evnts); var eventNames = (from eve in eventSearchResults select eve.event_name).ToList(); var eventImages = (from eve in eventSearchResults select eve.event_profile_image).ToList(); var eventId = (from eve in eventSearchResults select eve.C_ID.ToString()).ToList(); eventInfo.Add(eventNames); eventInfo.Add(eventImages); eventInfo.Add(eventId); returnJson.Add(userInfo); returnJson.Add(groupInfo); returnJson.Add(eventInfo); return(Json(returnJson)); }