Пример #1
0
        public ActionResult Index()
        {
            var model = new EventFeedViewModel();
            //var events = _eventService.FindEventsCreatedByUser(User.Identity.GetUserId());
            var allEvents = _eventService.GetAllEvents();

            var viewModels = allEvents.Select(e => new EventViewModel()
            {
                Event           = e,
                ViewerIsCreator = User.Identity.GetUserId().Equals(e.Creator.Id),
            }).OrderBy(m => m.Event.EventTime != null ? m.Event.EventTime.StartTime : DateTime.MinValue).ThenBy(m => m.Event.CreationTime);

            model.ViewersEvents = viewModels.Where(m => m.ViewerIsCreator || (m.Event.RSVPs != null && m.Event.RSVPs.Any(r => r.User.Id.Equals(User.Identity.GetUserId()) && (r.Response == RSVPStatus.Yes || r.Response == RSVPStatus.Maybe))));
            model.OtherEvents   = viewModels.Where(m => !model.ViewersEvents.Any(mm => mm.Event.Id == m.Event.Id));

            return(View(model));
        }
Пример #2
0
        public EventFeedViewModel GetEventFeed(int userId)
        {
            EventFeedViewModel eventFeed = new EventFeedViewModel();
            eventFeed.Groups = database.GetGroups(userId);
            eventFeed.SideBar = GetSideBar(userId);
            List<Event> events = GetEventsFromFriends(eventFeed.SideBar.UserList);
            events = events.Concat(database.GetEvents(userId)).ToList();
            events = events.Concat(GetEventsFromGroups(eventFeed.Groups)).ToList();
            events = GetSortedEventList(events);
            eventFeed.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
                {
                    eventFeed.Events.Add(temp);
                }

            }
            return eventFeed;
        }
Пример #3
0
 public ActionResult GetSideBar()
 {
     var service = new Service();
     User user = service.GetUser(User.Identity.Name);
     if (Request.IsAjaxRequest())
     {
         EventFeedViewModel model = new EventFeedViewModel();
         model.SideBar = service.GetSideBar(user.UserID, null);
         return Json(RenderPartialViewToString("SideBar", model), JsonRequestBehavior.AllowGet);
     }
     return View("Index");
 }