Beispiel #1
0
 public GroupFeedViewModel GetGroupFeed(int groupId, int userId)
 {
     GroupFeedViewModel groupFeed = new GroupFeedViewModel();
     groupFeed.Group = database.GetGroup(groupId);
     groupFeed.Groups = database.GetGroups(userId);
     groupFeed.SideBar = GetSideBar(userId, groupId);
     List<Event> events = database.GetGroupEvents(groupId);
     events = GetSortedEventList(events);
     groupFeed.Events = new List<EventViewModel>();
     foreach (Event e in events)
     {
         bool? attending;
         EventToUserRelation eventToUser = database.GetEventToUserRelation(e.EventID, userId);
         if (eventToUser == null)
         {
             attending = null;
         }
         else
         {
             attending = eventToUser.Answer;
         }
         // Checks if to add this to eventFeed
         EventViewModel temp = CastToViewModel(e, attending);
         // Adds all events to feed if user is attending or if the event has not expired.
         if (temp.Attending != true && (temp.State == State.OFF || temp.State == State.FULL || temp.State == State.ON))
         {
         }
         else
         {
             groupFeed.Events.Add(temp);
         }
     }
     return groupFeed;
 }
Beispiel #2
0
 public ActionResult GetSideBar(int groupId)
 {
     var service = new Service();
     User user = service.GetUser(User.Identity.Name);
     if (service.IsMemberOfGroup(user.UserID, groupId))
     {
         if (Request.IsAjaxRequest())
         {
             GroupFeedViewModel model = new GroupFeedViewModel();
             model.SideBar = service.GetSideBar(user.UserID, groupId);
             model.Group = service.GetGroupById(groupId);
             return Json(RenderPartialViewToString("SideBar", model), JsonRequestBehavior.AllowGet);
         }
     }
     return Json(null, JsonRequestBehavior.AllowGet);
 }