예제 #1
0
 public List<Hobby> getHobbiesByGroup(Group g)
 {
     var hobbies = (from c in db.HobbyGroupConnections
                   where g.ID == c.GroupID
                   join h in db.Hobbies on c.HobbyID equals h.ID
                   select h).ToList();
     return hobbies;
 }
예제 #2
0
        public bool addHobbyGroupConnection(Hobby h, Group g)
        {
            HobbyGroupConnection hConnection = new HobbyGroupConnection();
            hConnection.GroupID = g.ID;
            hConnection.HobbyID = h.ID;
            db.HobbyGroupConnections.Add(hConnection);

            return db.SaveChanges() != 0;
        }
예제 #3
0
        public ActionResult CreateGroup(FormCollection collection)
        {
            Group g = new Group();
            ApplicationUser currentUser = accountService.getUserByName(User.Identity.Name);
            List<Hobby> currentUserHobbies = hobbyService.getHobbiesByUser(currentUser);

            g.Name = collection["groupName"];
            g.Description = collection["groupDesc"];

            groupService.addGroup(g);

            foreach (Hobby h in currentUserHobbies)
            {
                if (collection[h.Name] == h.Name)
                {
                    hobbyService.addHobbyGroupConnection(h, g);
                }
            }

            groupService.addAdminToGroup(g, currentUser);

            string url = this.Request.UrlReferrer.AbsoluteUri;
            return Redirect(url);
        }
예제 #4
0
 public List<Status> getGroupStatusHistory(Group g)
 {
     var statuses = (from s in db.Statuses
                     where s.GroupID == g.ID
                     orderby s.Date descending
                     select s).ToList();
     return statuses;
 }